List of usage examples for java.util Locale getLanguage
public String getLanguage()
From source file:fi.helsinki.opintoni.integration.flamma.FlammaRestClient.java
public Feed getTeacherFeed(Locale locale) { String uri = getFeedUri(teacherFeedsByLocale.get(locale.getLanguage())); return restTemplate.getForObject(uri, Feed.class); }
From source file:com.bluexml.side.framework.alfresco.shareLanguagePicker.MyLocalResolver.java
public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) { logger.debug("setLocale " + locale.getLanguage()); request.getSession().setAttribute(LanguageSetter.SHARE_LANG, locale.getLanguage()); I18NUtil.setLocale(locale);/* w w w . j a v a 2 s. c o m*/ }
From source file:com.michellemay.mappings.ISO639Alpha3Mapping.java
/** * Instantiates a new ISO 639 alpha 3 mapping. *//*from www .j av a 2 s. co m*/ public ISO639Alpha3Mapping() { super(NAME); // Build reverse map HashMap<String, Locale> map = new HashMap<String, Locale>(); for (Locale loc : LocaleUtils.availableLocaleList()) { String isoCode = loc.getLanguage(); if (isoCode.length() > 0) { String displayValue = loc.getISO3Language().toLowerCase(); if (!map.containsKey(displayValue)) { map.put(displayValue, LocaleUtils.toLocale(isoCode)); } } } this.withMapping(map).withCaseSensitive(false); }
From source file:be.fedict.trust.service.bean.LocalizationServiceBean.java
/** * {@inheritDoc}/*from w ww.j a v a 2s .c om*/ */ public String findText(String key, Locale locale) { LOG.debug("find text: " + key + " language=" + locale.getLanguage()); LocalizationKeyEntity localizationKey = this.localizationDAO.findLocalization(key); if (null != localizationKey) { for (LocalizationTextEntity text : localizationKey.getTexts()) { if (text.getLanguage().equals(locale.getLanguage())) { return text.getText(); } } } return null; }
From source file:com.michellemay.mappings.LanguageTagsMapping.java
/** * Instantiates a new Language tags mapping. */// w w w . j a v a2s. c o m public LanguageTagsMapping() { super(NAME); this.withCaseSensitive(false); // Build reverse map. Use a tree map to offer case insensitiveness while preserving keys case (useful for extending) TreeMap<String, Locale> map = new TreeMap<String, Locale>( this.getCaseSensitive() ? null : String.CASE_INSENSITIVE_ORDER); for (Locale loc : LocaleUtils.availableLocaleList()) { String isoCode = loc.getLanguage(); if (isoCode.length() > 0) { String displayValue = loc.toLanguageTag(); if (!map.containsKey(displayValue)) { // Also add variant with underscores map.put(displayValue, loc); map.put(displayValue.replace('-', '_'), loc); } } } this.withMapping(map); }
From source file:com.seajas.search.utilities.spring.i18n.AcceptHeaderSessionLocaleResolver.java
/** * Determine the default locale from the HTTP request header. * //w w w . j av a 2s . c o m * @param request * @return Locale */ @Override protected Locale determineDefaultLocale(HttpServletRequest request) { Locale requestLocale = request.getLocale(); if (availableLanguages.contains(requestLocale.getLanguage())) return requestLocale; else return getDefaultLocale(); }
From source file:org.smigo.message.JdbcMessageDao.java
@Override public List<Message> getMessage(Locale locale, int from, int size) { final String whereParameter = locale.getLanguage() + "%"; return jdbcTemplate.query(SELECT, new Object[] { whereParameter, from, size }, new RowMapper<Message>() { @Override//w w w . j ava 2 s.c o m public Message mapRow(ResultSet rs, int rowNum) throws SQLException { return new Message(rs.getInt("id"), rs.getString("text"), rs.getString("username"), rs.getDate("createdate")); } }); }
From source file:de.cosmocode.commons.converter.LocaleLanguageIsoConverter.java
@Override public String encode(Locale input) { return toThreeLetter(input.getLanguage()); }
From source file:fi.helsinki.opintoni.integration.flamma.FlammaRestClient.java
public Feed getStudentOpenUniversityFeed(Locale locale) { String uri = getFeedUri(studentOpenUniversityFeedsByLocale.get(locale.getLanguage())); return restTemplate.getForObject(uri, Feed.class); }
From source file:com.assemblade.utils.localisation.Localiser.java
private Localiser() { localisedStrings = new Properties(); Locale current = Locale.getDefault(); String language = current.getLanguage(); String propertyFile = language + ".properties"; InputStream is = Localiser.class.getClassLoader().getResourceAsStream(propertyFile); if (is != null) { propertyFile = "en.properties"; is = Localiser.class.getClassLoader().getResourceAsStream(propertyFile); }/*from w ww . j a va 2 s.c om*/ if (is != null) { try { localisedStrings.load(is); } catch (IOException e) { log.error("Failed to load localised properties from resource: " + propertyFile, e); } } else { log.error("Could not find default localisation property file: " + propertyFile); } }