Example usage for java.util Locale getLanguage

List of usage examples for java.util Locale getLanguage

Introduction

In this page you can find the example usage for java.util Locale getLanguage.

Prototype

public String getLanguage() 

Source Link

Document

Returns the language code of this Locale.

Usage

From source file:fi.helsinki.opintoni.integration.leiki.LeikiRestClient.java

@Override
public List<LeikiCategoryHit> searchCategory(String searchTerm, Locale locale) {
    URI uri = UriComponentsBuilder.fromHttpUrl(baseUrl).path("/focus/api")
            .queryParam("method", "searchcategories").queryParam("autocomplete", "occurred")
            .queryParam("lang", locale.getLanguage()).queryParam("text", searchTerm)
            .queryParam("format", "json").queryParam("max", maxCategoryResults).build().encode().toUri();

    return getLeikiCategoryData(uri, new ParameterizedTypeReference<LeikiCategoryResponse<LeikiCategoryHit>>() {
    });//from ww  w.j a  va  2  s. co m
}

From source file:fi.helsinki.opintoni.integration.unisport.UnisportRestClient.java

@Override
public UnisportUserReservations getUserReservations(Long unisportUserId, Locale locale) {
    return restTemplate.exchange("{baseUrl}/api/v1/{locale}/ext/opintoni/reservations", HttpMethod.GET,
            getAuthorizationHeader(unisportUserId), new ParameterizedTypeReference<UnisportUserReservations>() {
            }, baseUrl, locale.getLanguage()).getBody();
}

From source file:com.cburch.logisim.util.LocaleManager.java

private void loadLocale(Locale loc) {
    String bundleName = dir_name + "/" + loc.getLanguage() + "/" + file_start;
    locale = ResourceBundle.getBundle(bundleName, loc);
}

From source file:org.jasig.cas.web.view.CasReloadableMessageBundle.java

@Override
protected String getMessageInternal(final String code, final Object[] args, final Locale locale) {
    boolean foundCode = false;

    if (!locale.equals(Locale.ENGLISH)) {
        for (int i = 0; !foundCode && i < this.basenames.length; i++) {
            final String filename = this.basenames[i] + "_" + locale.getLanguage();

            logger.debug("Examining language bundle [{}] for the code [{}]", filename, code);
            final PropertiesHolder holder = this.getProperties(filename);
            foundCode = holder != null && holder.getProperties() != null && holder.getProperty(code) != null;
        }/* w ww  . j a  va 2 s. c  o m*/

        if (!foundCode) {
            logger.warn("The code [{}] cannot be found in the language bundle for the locale [{}]", code,
                    locale);
        }
    }
    return super.getMessageInternal(code, args, locale);
}

From source file:io.cfp.service.email.EmailingService.java

protected String getTemplatePath(final String emailTemplate, final Locale locale) {
    String language = locale.getLanguage();
    if (!"fr".equals(language)) {
        language = "en";
    }/*from  w  w w.j  ava  2s  .  c  o m*/
    return "mails/" + language + "/" + emailTemplate;
}

From source file:es.pode.visualizador.presentacion.descargas.DescargasControllerImpl.java

/**
 * @see es.pode.visualizador.presentacion.descargas.DescargasController#listadoDescargas(org.apache.struts.action.ActionMapping, es.pode.visualizador.presentacion.descargas.ListadoDescargasForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *///from  w w w . j a v a2 s  .  com
public final void listadoDescargas(ActionMapping mapping,
        es.pode.visualizador.presentacion.descargas.ListadoDescargasForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    try {
        Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
        String idioma = locale.getLanguage();
        logger.debug("Recuperado idioma :" + idioma);
        DescargaVO descargas[] = getSrvDescargas().obtenerDescargasActivas();
        logger.debug("Recuperadas " + descargas.length != null ? descargas.length : 0 + " descargas");
        ArrayList<DescargaInfo> listaDescargas = new ArrayList<DescargaInfo>();
        if (descargas != null && descargas.length > 0) {

            DescDescargaVO[] descs = getSrvDescargas().obtenerDescDescargasIdioma(descargas, idioma);
            logger.debug("Recuperadas " + descs.length + " descripciones de descargas");
            for (int i = 0; i < descargas.length; i++) {
                DescargaInfo info = new DescargaInfo();
                info.setTitulo(descs[i] != null && descs[i].getTitulo() != null ? descs[i].getTitulo() : VACIA);
                info.setDescripcion(
                        descs[i] != null && descs[i].getDescripcion() != null ? descs[i].getDescripcion()
                                : VACIA);
                info.setIdentificador(descargas[i] != null && descargas[i].getIdentificador() != null
                        ? descargas[i].getIdentificador().toString()
                        : VACIA);
                info.setPeso(
                        descargas[i] != null && descargas[i].getPeso() != null ? descargas[i].getPeso() : 0L,
                        locale);
                info.setRuta(descargas[i] != null && descargas[i].getPath() != null
                        ? request.getServerName() + "/" + descargas[i].getPath()
                        : VACIA);
                listaDescargas.add(info);
            }
        }
        logger.debug("Lista de descargas construida");
        form.setDescargas(listaDescargas);
    } catch (Exception e) {
        logger.debug("Error al recuperar descargas.", e);
        throw new ValidatorException("{listaDescargas.error}");
    }
}

From source file:im.bci.gamesitekit.GameSiteKitMain.java

private void buildHtml(Locale locale)
        throws SAXException, IOException, TemplateException, ParserConfigurationException {
    Path localeOutputDir = outputDir.resolve(locale.getLanguage());
    Files.createDirectories(localeOutputDir);
    HashMap<String, Object> model = new HashMap<>();
    model.put("screenshots", createScreenshotsMV(localeOutputDir));
    model.put("lastUpdate", new Date());
    freemakerConfiguration.setLocale(locale);
    freemakerConfiguration.addAutoImport("manifest", "manifest.ftl");
    for (String file : Arrays.asList("index", "support")) {
        try (BufferedWriter w = Files.newBufferedWriter(localeOutputDir.resolve(file + ".html"),
                Charset.forName("UTF-8"))) {
            freemakerConfiguration.getTemplate(file + ".ftl").process(model, w);
        }//  w ww.  j  a v  a 2 s  .c  o m
    }
}

From source file:org.smigo.species.vernacular.JdbcVernacularDao.java

@Override
public List<Vernacular> getVernacularsByLocale(Locale locale) {
    //if country exists and matches, sort first, else by id
    final String sql = "SELECT * FROM VERNACULARS WHERE LANGUAGE = ? ORDER BY COUNTRY = ? OR ?='' DESC, ID;";
    return jdbcTemplate.query(sql, vernacularRowMapper, locale.getLanguage(), locale.getCountry(),
            locale.getCountry());/*from w  w  w.j  a  v  a  2 s  .  c om*/
}

From source file:io.uengine.web.configuration.ConfigurationController.java

/**
 *  ??   ? .//from ww w .  ja  v a2 s  .c  o  m
 */
@RequestMapping(value = "bundle", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public Response getBundle(final Locale locale) throws IOException {
    Response response = new Response();
    try {
        Map map = Messages.toMap(locale);
        map.put("browser.language", locale.getLanguage());
        map.put("browser.country", locale.getCountry());
        map.put("browser.locale", locale.toString());

        MultiValueMap headers = new HttpHeaders();
        response.getMap().putAll(map);
        response.setSuccess(true);
    } catch (Exception ex) {
        response.getError().setMessage(ex.getMessage());
        if (ex.getCause() != null)
            response.getError().setCause(ex.getCause().getMessage());
        response.getError().setException(ExceptionUtils.getFullStackTrace(ex));
    }
    return response;
}

From source file:net.bible.android.BibleApplication.java

@Override
public void onCreate() {
    super.onCreate();

    // save to a singleton to allow easy access from anywhere
    singleton = this;

    Log.i(TAG, "OS:" + System.getProperty("os.name") + " ver " + System.getProperty("os.version"));
    Log.i(TAG, "Java:" + System.getProperty("java.vendor") + " ver " + System.getProperty("java.version"));
    Log.i(TAG, "Java home:" + System.getProperty("java.home"));
    Log.i(TAG,//w w w  . j a  v a 2 s  . co m
            "User dir:" + System.getProperty("user.dir") + " Timezone:" + System.getProperty("user.timezone"));

    // fix for null context class loader (http://code.google.com/p/android/issues/detail?id=5697)
    // this affected jsword dynamic classloading
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());

    installJSwordErrorReportListener();

    // some changes may be required for different versions
    upgradePersistentData();

    // initialise link to Android progress control display in Notification bar
    ProgressNotificationManager.getInstance().initialise();

    allowLocaleOverride();
    Locale locale = Locale.getDefault();
    Log.i(TAG, "Locale language:" + locale.getLanguage() + " Variant:" + locale.getDisplayName());

    screenTimeoutSettings.overrideScreenTimeout();

    // various initialisations required every time at app startup
    Initialisation.getInstance().initialiseEventually();
}