List of usage examples for java.util Locale toString
@Override public final String toString()
Locale
object, consisting of language, country, variant, script, and extensions as below: language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensionsLanguage is always lower case, country is always upper case, script is always title case, and extensions are always lower case.
From source file:info.magnolia.cms.i18n.DefaultI18nContentSupport.java
@Override protected String toRawURI(String i18nURI, Locale locale) { //MAGNOLIA-2142 - make sure we strip language only when it is actually present String raw = StringUtils.removeStart(i18nURI, "/" + locale.toString() + "/"); // put back leading slash if removed while stripping language identifier return raw == null || raw.startsWith("/") ? raw : ("/" + raw); }
From source file:com.rest.EmailSender.java
public void sendVerificationTokenEmail(String emailVerificationToken, String requestBaseUrl) { Locale locale = LocaleContextHolder.getLocale(); String emailVerificationTemplate = ""; switch (locale.toString()) { case "fr": emailVerificationTemplate = "emailVerificationTemplate_fr"; break;//w ww . j a v a2s . com default: emailVerificationTemplate = "emailVerificationTemplate_en"; break; } Context ctx = new Context(); ctx.setVariable("emailVerificationToken", emailVerificationToken.toString()); ctx.setVariable("requestBaseUrl", requestBaseUrl.toString()); String emailText = thymeleaf.process(emailVerificationTemplate, ctx); try { sendMessage(bundleMessageReader.getMessage("EmailVerificationEmailHeader"), emailText); } catch (MessagingException e) { e.printStackTrace(); } }
From source file:org.kootox.episodesmanager.EpisodesManagerConfig.java
public void setLocale(Locale locale) { applicationConfig.setOption(LOCALE.key, locale.toString()); }
From source file:net.ymate.platform.webmvc.support.I18NWebEventHandler.java
public void onChanged(Locale locale) { if (WebContext.getContext() != null && locale != null) { CookieHelper.bind(WebContext.getContext().getOwner()).setCookie(I18N_LANG_KEY, locale.toString()); }/* w w w . j a v a 2s . c om*/ }
From source file:org.jspringbot.keyword.i18n.I18nHelper.java
public String getMessage(String code) { Locale locale = getLocale(); LOG.keywordAppender().appendProperty("Message Code", code).appendProperty("Locale ID", locale.toString()); if (StringUtils.isNotBlank(locale.getDisplayCountry())) { LOG.keywordAppender().appendProperty("Display Country", locale.getDisplayCountry()); }//from ww w .j a va 2 s . c o m if (StringUtils.isNotBlank(locale.getDisplayLanguage())) { LOG.keywordAppender().appendProperty("Display Language", locale.getDisplayLanguage()); } String message = messages.getMessage(code); LOG.keywordAppender().appendProperty("Message Value", message); return message; }
From source file:org.kootox.episodesmanager.EpisodesManagerConfig.java
public void setApiLocale(Locale locale) { applicationConfig.setOption(API_LOCALE.key, locale.toString()); }
From source file:com.dm.wallpaper.board.fragments.dialogs.LanguagesFragment.java
private void getLanguages() { mGetLanguages = new AsyncTask<Void, Void, Boolean>() { List<Language> languages; int index = 0; @Override// w w w . j a v a 2 s.co m protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); languages = LocaleHelper.getAvailableLanguages(getActivity()); Locale locale = Preferences.get(getActivity()).getCurrentLocale(); for (int i = 0; i < languages.size(); i++) { Locale l = languages.get(i).getLocale(); if (l.toString().equals(locale.toString())) { index = i; break; } } return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; } @Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); if (aBoolean) { mListView.setAdapter(new LanguagesAdapter(getActivity(), languages, index)); } else { dismiss(); } mGetLanguages = null; } }.execute(); }
From source file:com.fredhopper.core.connector.index.generate.writer.CategoryCsvWriter.java
@Override public void print(final FhCategoryData source) throws IOException { Preconditions.checkArgument(source != null); Preconditions.checkArgument(!CollectionUtils.isEmpty(source.getNames())); final Map<Locale, String> names = source.getNames(); for (final Locale locale : names.keySet()) { final String parentId = source.getParentId() == null ? source.getCategoryId() : source.getParentId(); printLine(source.getCategoryId(), parentId, locale.toString(), source.getNames().get(locale)); }// w w w . ja v a 2 s.com }
From source file:com.inversoft.json.LocaleSerializer.java
@Override public void serialize(Locale value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (value == null) { jgen.writeNull();// w w w . j a v a 2s . c om } else { jgen.writeString(value.toString()); } }
From source file:org.apereo.portal.soffit.DefinitionHeaderProvider.java
@Override public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) { // Username/*from w w w . j a v a 2 s. c o m*/ final String username = getUsername(renderRequest); // Obtain the MarketplacePortletDefinition for this soffit final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest(); final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, renderRequest.getWindowID()); final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId); final IPortletDefinition pdef = portletWindow.getPortletEntity().getPortletDefinition(); final MarketplacePortletDefinition mpdef = this.marketplaceService .getOrCreateMarketplacePortletDefinition(pdef); final IPerson user = personManager.getPerson(httpr); final Locale locale = getUserLocale(user); // Title final String title = mpdef.getTitle(locale.toString()); // FName final String fname = mpdef.getFName(); // Description final String description = mpdef.getDescription(locale.toString()); // Categories List<String> categories = new ArrayList<>(); for (PortletCategory pc : mpdef.getCategories()) { categories.add(pc.getName()); } // Parameters Map<String, List<String>> parameters = new HashMap<>(); for (IPortletDefinitionParameter param : mpdef.getParameters()) { parameters.put(param.getName(), Collections.singletonList(param.getValue())); } final Definition definition = definitionService.createDefinition(title, fname, description, categories, parameters, username, getExpiration(renderRequest)); final Header rslt = new BasicHeader(Headers.DEFINITION.getName(), definition.getEncryptedToken()); logger.debug("Produced the following {} header for username='{}': {}", Headers.DEFINITION.getName(), username, rslt); return rslt; }