List of usage examples for java.util Locale getLanguage
public String getLanguage()
From source file:com.haulmont.cuba.core.sys.FormatStringsRegistryImpl.java
@Nullable @Override/* w w w . j a va2s . c om*/ public FormatStrings getFormatStrings(Locale locale) { if (useLocaleLanguageOnly) locale = Locale.forLanguageTag(locale.getLanguage()); return formatStringsMap.get(locale); }
From source file:com.sample.application.email.srv.EmailTemplateRepositoryImp.java
@Override public String getFrom(String template, Locale locale) { String templateName = template + ((locale == null ? "" : "-" + locale.getLanguage())); return emailTemplates.getTemplateMap().get(templateName).getFrom(); }
From source file:com.sample.application.email.srv.EmailTemplateRepositoryImp.java
@Override public String getSubject(String template, Locale locale) { String templateName = template + ((locale == null ? "" : "-" + locale.getLanguage())); return emailTemplates.getTemplateMap().get(templateName).getSubject(); }
From source file:de.berlios.jhelpdesk.web.preferences.LookAndFeelEditController.java
private Cookie createCookie(HttpServletRequest req, Locale loc) { Cookie cookie = new Cookie("jhd_locale", loc.getLanguage()); cookie.setMaxAge(SECONDS_BY_WEEK);/*ww w.j a v a 2 s .c om*/ cookie.setPath(req.getContextPath()); return cookie; }
From source file:net.sourceforge.atunes.kernel.modules.state.LocaleBean.java
/** * Constructs LocaleBean from a given java.util.Locale * /*from w w w . jav a 2s . c o m*/ * @param locale * locale */ public LocaleBean(final Locale locale) { this.language = locale.getLanguage(); this.country = locale.getCountry(); }
From source file:com.qcadoo.customTranslation.internal.CustomTranslationResolverImpl.java
@Override public boolean isCustomTranslationActive(final String key, final Locale locale) { return customTranslationCacheService.isCustomTranslationActive(key, locale.getLanguage()); }
From source file:com.jeanchampemont.notedown.utils.UserLocaleResolver.java
@Override public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) { User user = authenticationService.getCurrentUser(); user.setLocale(locale.getLanguage()); userService.update(user);//from w w w.jav a 2s . c om }
From source file:com.hypersocket.i18n.json.I18NController.java
@RequestMapping(value = "i18n/locales", method = RequestMethod.GET, produces = { "application/json" }) @ResponseBody/*from w w w . j a v a2 s . c o m*/ @ResponseStatus(value = HttpStatus.OK) public ResourceList<SelectOption> getLocales(HttpServletRequest request, HttpServletResponse response) throws AccessDeniedException, UnauthorizedException { List<SelectOption> locales = new ArrayList<SelectOption>(); for (Locale l : i18nService.getSupportedLocales()) { locales.add(new SelectOption(l.getLanguage(), l.getLanguage())); } return new ResourceList<SelectOption>(locales); }
From source file:info.magnolia.module.admininterface.dialogs.LanguageSelect.java
/** * @see info.magnolia.cms.gui.dialog.DialogSelect#init(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, info.magnolia.cms.core.Content, info.magnolia.cms.core.Content) *///from w w w .j ava 2 s .c om public void init(HttpServletRequest request, HttpServletResponse response, Content websiteNode, Content configNode) throws RepositoryException { super.init(request, response, websiteNode, configNode); List options = new ArrayList(); Collection col = MessagesManager.getAvailableLocales(); for (Iterator iter = col.iterator(); iter.hasNext();) { Locale locale = (Locale) iter.next(); String code = locale.getLanguage(); if (StringUtils.isNotEmpty(locale.getCountry())) { code += "_" + locale.getCountry(); //$NON-NLS-1$ } String name = locale.getDisplayName(MgnlContext.getLocale()); SelectOption option = new SelectOption(name, code); options.add(option); } // sort them Collections.sort(options, new Comparator() { public int compare(Object arg0, Object arg1) { try { String name0 = ((SelectOption) arg0).getLabel(); String name1 = ((SelectOption) arg1).getLabel(); return name0.compareTo(name1); } catch (Exception e) { return 0; } } }); this.setOptions(options); }
From source file:org.obm.opush.AutodiscoverHandlerTest.java
private String formatCultureParameter(Locale locale) { return locale.getLanguage().toLowerCase() + ":" + locale.getCountry().toLowerCase(); }