List of usage examples for java.util Locale getLanguage
public String getLanguage()
From source file:com.basicservice.controller.AdminController.java
private void prepareContext(Map map, HttpServletResponse response) { Map constants = service.getConstants(); String csrf_token = "<secret changing key>"; // use SecureRandom to generate a random token Locale locale = LocaleContextHolder.getLocale(); map.put("locale", locale.getLanguage()); map.put("constants", constants); if (response != null) { map.put("csrf_token", csrf_token); Cookie cookie = new Cookie(Constants.CSRF_COOKIE_NAME, csrf_token); cookie.setPath("/"); cookie.setMaxAge(-1);/*from w w w. java 2 s .co m*/ response.addCookie(cookie); } }
From source file:org.jspringbot.keyword.i18n.I18nHelper.java
public String getLanguage() { Locale locale = getLocale(); LOG.keywordAppender().appendProperty("Locale Language", locale.getLanguage()); return locale.getLanguage(); }
From source file:org.businessmanager.web.converter.CountryConverterOutput.java
@Override public String getAsString(FacesContext context, UIComponent component, Object value) { if (value == null || value.equals("")) { return ""; }/*from w w w . j av a2 s . c o m*/ if (value instanceof Country) { return ((Country) value).getName(); } else if (value instanceof String) { Locale locale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale(); Country country = openGeoDb.getCountryByCode(locale.getLanguage(), (String) value); if (country != null) { return country.getName(); } } return ""; }
From source file:org.ocsoft.olivia.logger.OliviaLog.java
/** * ??????.<br>//from w ww. ja v a 2 s.c o m * ?????????. * @param locale ? * @return ???? */ @Nonnull public String getMessage(Locale locale) { String message = logData.get("message." + locale.getLanguage()); if (message == null) return getMessage(); return message; }
From source file:de.brendamour.jpasskit.signing.PKPassTemplateInMemory.java
private String pathForLocale(String pathInTemplate, Locale locale) { if (locale == null) { return pathInTemplate; }//from w w w.java2 s .co m return locale.getLanguage() + ".lproj" + File.separator + pathInTemplate; }
From source file:de.micromata.genome.gwiki.page.impl.wiki.macros.GWikiIfMacro.java
public boolean checkCondition(GWikiContext ctx, MacroAttributes attrs) { if (StringUtils.isNotEmpty(lang) == true) { Locale uloc = ctx.getWikiWeb().getAuthorization().getCurrentUserLocale(ctx); if (uloc.getLanguage().equals(lang) == true) { return true; }// ww w. j a va 2 s . c o m return false; } else if (StringUtils.isNotEmpty(right) == true) { if (right.equals("EDIT") == true) { return ctx.getWikiWeb().getAuthorization().isAllowToEdit(ctx, ctx.getCurrentElement().getElementInfo()); } if (ctx.isAllowTo(right) == true) { return true; } return false; } else if (StringUtils.isNotEmpty(renderMode) == true) { RenderModes rm = RenderModes.getRenderMode(renderMode); if (rm == null) { return true; } return rm.isSet(ctx.getRenderMode()); } return true; }
From source file:info.magnolia.ui.framework.i18n.DefaultI18NAuthoringSupport.java
@Override public String deriveLocalisedPropertyName(String base, Locale locale) { return String.format("%s_%s", base, locale.getLanguage()); }
From source file:com.swtxml.i18n.ResourceBundleLabelTranslator.java
private List<String> getResourceBundleNames(String baseName, Locale locale) { List<String> results = new ArrayList<String>(4); if (StringUtils.isNotEmpty(locale.getLanguage())) { if (StringUtils.isNotEmpty(locale.getCountry())) { if (StringUtils.isNotEmpty(locale.getVariant())) { results.add(baseName + "_" + locale.getLanguage() + "_" + locale.getCountry() + "_" + locale.getVariant()); }// www. j a va 2s. c o m results.add(baseName + "_" + locale.getLanguage() + "_" + locale.getCountry()); } results.add(baseName + "_" + locale.getLanguage()); } results.add(baseName); return results; }
From source file:alfio.repository.TicketFieldRepository.java
default Map<Integer, TicketFieldDescription> findTranslationsFor(Locale locale, int eventId) { return findDescriptions(eventId, locale.getLanguage()).stream().collect( Collectors.toMap(TicketFieldDescription::getTicketFieldConfigurationId, Function.identity())); }
From source file:cn.edu.zjnu.acm.judge.contest.ContestController.java
public List<Problem> problems(@PathVariable("contestId") long contest, Locale locale) { // TODO user is empty return contestMapper.getProblems(contest, null, locale.getLanguage()); }