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:architecture.ee.component.core.lifecycle.ConfigServiceImpl.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public void setLocalizedApplicationProperty(String name, String value, Locale locale) { getLocalizedApplicationProperties()/*from w w w .j a v a 2 s . co m*/ .put((new StringBuilder()).append(name).append(".").append(locale.toString()).toString(), value); }
From source file:com.liferay.portal.language.LanguageUtil.java
private LanguageUtil() { String[] array = StringUtil.split(PropsUtil.get(PropsUtil.LOCALES), StringPool.COMMA); _locales = new Locale[array.length]; _localesByLanguageCode = CollectionFactory.getHashMap(); _charEncodings = CollectionFactory.getHashMap(); for (int i = 0; i < array.length; i++) { int x = array[i].indexOf(StringPool.UNDERLINE); String language = array[i].substring(0, x); String country = array[i].substring(x + 1, array[i].length()); Locale locale = new Locale(language, country); _locales[i] = locale;// w ww . jav a2 s . com _localesByLanguageCode.put(language, locale); _charEncodings.put(locale.toString(), DEFAULT_ENCODING); } }
From source file:architecture.ee.component.core.lifecycle.ConfigServiceImpl.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public void deleteLocalizedApplicationProperty(String name, Locale locale) { getLocalizedApplicationProperties()//from w w w .j ava2s .co m .remove((new StringBuilder()).append(name).append(".").append(locale.toString()).toString()); }
From source file:org.b3log.solo.processor.console.AdminConsole.java
/** * Shows administrator functions with the specified context. * /* www. ja v a2 s . c o m*/ * @param request the specified request * @param context the specified context */ @RequestProcessing(value = { "/admin-article.do", "/admin-article-list.do", "/admin-comment-list.do", "/admin-link-list.do", "/admin-page-list.do", "/admin-others.do", "/admin-draft-list.do", "/admin-user-list.do", "/admin-plugin-list.do", "/admin-main.do", "/admin-about.do" }, method = HTTPRequestMethod.GET) public void showAdminFunctions(final HttpServletRequest request, final HTTPRequestContext context) { final AbstractFreeMarkerRenderer renderer = new ConsoleRenderer(); context.setRenderer(renderer); final String requestURI = request.getRequestURI(); final String templateName = StringUtils.substringBetween(requestURI, Latkes.getContextPath() + '/', ".") + ".ftl"; LOGGER.log(Level.FINEST, "Admin function[templateName={0}]", templateName); renderer.setTemplateName(templateName); final Locale locale = Latkes.getLocale(); final Map<String, String> langs = langPropsService.getAll(locale); final Map<String, Object> dataModel = renderer.getDataModel(); dataModel.putAll(langs); Keys.fillServer(dataModel); Keys.fillRuntime(dataModel); dataModel.put(Preference.LOCALE_STRING, locale.toString()); fireFreeMarkerActionEvent(templateName, dataModel); }
From source file:com.redhat.rhn.common.localization.XmlMessages.java
/** Gets the resource bundle, first checking our internal cache * @param bundleName name of the resource bundle * @param locale locale used to retrieve the resource bundle * @return the resource bundle for the given bundleName and locale, * always non-null. (An exception is thrown if the bundle can't be found.) *///from ww w. ja v a 2 s. c om protected ResourceBundle getBundle(final String bundleName, final Locale locale) { // Construct the key to the Map of Bundles // that is a combination of the bundlename // plus the locale StringBuilder bundleBuff = new StringBuilder(bundleName); if (locale != null) { bundleBuff.append("."); bundleBuff.append(locale.toString()); } String bundleKey = bundleBuff.toString(); // Check the local in memory cache of the bundles // to see if it has been loaded already. ResourceBundle retval = bundles.get(bundleKey); if (retval != null) { // System.out.println("Got bundle from cache, returning : " + bundleKey); return retval; } // System.out.println("Reloading BUNDLE : " + bundleKey); StringBuilder urlName = new StringBuilder("/" + bundleName.replace('.', '/')); // if we specified a locale // then make sure we tack it on to the filename // to be loaded. if (locale != null) { urlName.append("_"); urlName.append(locale.toString()); } urlName.append(".xml"); try { synchronized (this) { retval = new XmlResourceBundle(urlName.toString()); bundles.put(bundleKey, retval); } } catch (IOException ioe) { if (LOG.isDebugEnabled()) { LOG.debug("Resource bundle not found: " + ioe.toString() + ", url: " + urlName); } throw new java.util.MissingResourceException("Resource bundle not found", bundleName, ""); } return retval; }
From source file:org.hoteia.qalingo.core.i18n.message.CoreMessageSource.java
public String getMessage(final MessageSourceResolvable resolvable, final Locale locale) throws NoSuchMessageException { try {/*from www .j a v a 2s . c o m*/ return messageSource.getMessage(resolvable, locale); } catch (Exception e) { logger.info("This message key doesn't exist: " + resolvable.getCodes() + ", for this locale: " + locale.toString()); if (BooleanUtils.negate(locale.toString().equalsIgnoreCase(Constants.DEFAULT_LOCALE_CODE))) { return getMessage(resolvable, new Locale(Constants.DEFAULT_LOCALE_CODE)); } } return null; }
From source file:org.hoteia.qalingo.core.i18n.message.CoreMessageSource.java
public String getMessage(final String code, final Object args[], final String defaultMessage, final Locale locale) { try {/* www . j av a2 s . c om*/ return messageSource.getMessage(code, args, defaultMessage, locale); } catch (Exception e) { if (code != null && code.contains("javax")) { logger.info("This message key doesn't exist: " + code + ", for this locale: " + locale.toString()); } else { logger.info("This message key doesn't exist: " + code + ", for this locale: " + locale.toString()); } if (BooleanUtils.negate(locale.toString().equalsIgnoreCase(Constants.DEFAULT_LOCALE_CODE))) { return getMessage(code, args, defaultMessage, new Locale(Constants.DEFAULT_LOCALE_CODE)); } } return null; }
From source file:org.eclipse.jubula.client.core.model.TestDataCubePO.java
/** * FIXME Katrin This method should not be public! * <b>Only use this for internal purposes</b> * method to set the completeTdFlag for a given Locale * @param loc locale, for which to set the completeTdFlag * @param flag the state of completeTdFlag to set *///www. jav a2s . c o m public void setCompleteTdFlag(Locale loc, boolean flag) { getCompleteTdMap().put(loc.toString(), Boolean.valueOf(flag)); }
From source file:org.gitana.platform.client.node.NodeImpl.java
@Override public Node readTranslation(String edition, Locale locale) { String uri = getResourceUri() + "/i18n?locale=" + locale.toString(); if (edition != null) { uri += "&edition=" + edition; }/*from www . java2 s . c o m*/ Response response = getRemote().get(uri); return (Node) getFactory().node(getBranch(), response); }
From source file:org.eclipse.jubula.client.core.model.TestDataCubePO.java
/** * method to get the CompleteTdFlag for a given Locale * @param loc locale, for which to get the completeTdFlag * @return the state of completeTdFlag/*from ww w. j a va 2 s .c om*/ */ public boolean getCompleteTdFlag(Locale loc) { Boolean value = getCompleteTdMap().get(loc.toString()); return (value != null) ? value.booleanValue() : false; }