List of usage examples for java.util Locale getDisplayLanguage
public String getDisplayLanguage(Locale inLocale)
From source file:com.juce.JuceAppActivity.java
public static final String getLocaleValue (boolean isRegion) { java.util.Locale locale = java.util.Locale.getDefault(); return isRegion ? locale.getDisplayCountry (java.util.Locale.US) : locale.getDisplayLanguage (java.util.Locale.US); }
From source file:org.jahia.taglibs.internal.uicomponents.DisplayLanguageCodeTag.java
public int doStartTag() { // Produce the HTML code try {//from w w w . j a va2s. co m JspWriter out = pageContext.getOut(); StringBuilder str = new StringBuilder(); if (debug) { str.append("\n<!-- ======================================================================= -->\n"); str.append("<!-- The following HTML code is generated by 'DisplayLanguageCodeTag' taglib -->\n"); str.append("<!----------------------------------------------------------------------------->\n"); } if (!"".equals(_href)) { str.append("<a "); if (!"".equals(_style)) { str.append("class=\""); str.append(_style); str.append("\" "); } str.append("href=\""); str.append(_href); str.append("\">"); } Locale localeLangToDisplay = LanguageCodeConverters.languageCodeToLocale(_code); str.append(StringEscapeUtils.escapeHtml(localeLangToDisplay.getDisplayLanguage(localeLangToDisplay))); if (!"".equals(_href)) { str.append("</a>"); } if (debug) { str.append("\n<!-- ======================================================================= -->\n"); } out.print(str.toString()); } catch (IOException ioe) { logger.debug(ioe.toString()); } return SKIP_BODY; }
From source file:com.cryart.sabbathschool.viewmodel.SSQuarterliesViewModel.java
private String getDisplayLanguageByCode(String languageCode) { Locale locale = new Locale(languageCode); return org.apache.commons.lang3.StringUtils.capitalize(locale.getDisplayLanguage(Locale.getDefault())); }
From source file:info.magnolia.templating.elements.InitElement.java
@Override public void begin(Appendable out) throws IOException, RenderException { if (!isAdmin()) { return;//from ww w. ja v a2 s . c o m } Node content = getPassedContent(); if (content == null) { content = currentContent(); } TemplateDefinition templateDefinition = getRequiredTemplateDefinition(); dialog = resolveDialog(templateDefinition); Sources src = new Sources(MgnlContext.getContextPath()); MarkupHelper helper = new MarkupHelper(out); helper.append("<!-- begin js and css added by @cms.init -->\n"); helper.append("<meta name=\"gwt:property\" content=\"locale=" + i18nContentSupport.getLocale() + "\"/>\n"); helper.append(src.getHtmlCss()); helper.append(src.getHtmlJs()); //TODO see SCRUM-1239, we will probably get rid of the init tag in 5.0 //helper.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + PAGE_EDITOR_CSS + "\"></link>\n"); //helper.append("<script type=\"text/javascript\" src=\"" + PAGE_EDITOR_JS_SOURCE + "\"></script>\n"); helper.openComment(CMS_PAGE_TAG); if (content != null) { helper.attribute(AreaDirective.CONTENT_ATTRIBUTE, getNodePath(content)); } helper.attribute("dialog", dialog); helper.attribute("preview", String.valueOf(MgnlContext.getAggregationState().isPreviewMode())); //here we provide the page editor with the available locales and their respective URI for the current page if (i18nAuthoringSupport.isEnabled() && i18nContentSupport.isEnabled() && i18nContentSupport.getLocales().size() > 1) { Content currentPage = MgnlContext.getAggregationState().getMainContent(); String currentUri = createURI(currentPage, i18nContentSupport.getLocale()); helper.attribute("currentURI", currentUri); List<String> availableLocales = new ArrayList<String>(); for (Locale locale : i18nContentSupport.getLocales()) { String uri = createURI(currentPage, locale); String label = StringUtils.capitalize(locale.getDisplayLanguage(locale)); if (StringUtils.isNotEmpty(locale.getCountry())) { label += " (" + StringUtils.capitalize(locale.getDisplayCountry()) + ")"; } availableLocales.add(label + ":" + uri); } helper.attribute("availableLocales", StringUtils.join(availableLocales, ",")); } helper.append(" -->\n"); helper.closeComment(CMS_PAGE_TAG); }
From source file:org.orcid.frontend.web.util.LanguagesMap.java
/** * Returns the language translated in the given user locale * //from w ww . j a v a2 s. c o m * @param locale * @param userLocal * * @return The language translated to the given locale. * */ @Cacheable(value = "languages-map", key = "#locale.toString() + '-' + #userLocale.toString()") public String buildLanguageValue(Locale locale, Locale userLocale) { if (userLocale != null && userLocale.getLanguage().equals("xx")) { return X; } String variant = locale.getVariant(); String displayVariant = locale.getDisplayVariant(userLocale); String language = WordUtils.capitalize(locale.getDisplayLanguage(userLocale)); if (StringUtils.isEmpty(variant)) if (StringUtils.isEmpty(locale.getDisplayCountry(userLocale))) return language; else return language + " (" + locale.getDisplayCountry(userLocale) + ')'; else if (StringUtils.isEmpty(locale.getDisplayCountry(userLocale))) return language + ' ' + displayVariant; else return language + ' ' + displayVariant + " (" + locale.getDisplayCountry(userLocale) + ')'; }
From source file:de.nico.ha_manager.activities.Preferences.java
@SuppressWarnings("deprecation") private void setLanguage() { Preference language = findPreference("pref_app_language"); // Locale of HW-Manager Locale appLoc = getResources().getConfiguration().locale; // Locale of device Locale devLoc = Locale.getDefault(); if (devLoc.equals(appLoc)) { language.setSummary(getString(R.string.pref_language_default)); } else {//from w ww . ja v a2 s . c om language.setSummary(appLoc.getDisplayLanguage(appLoc)); } }
From source file:de.sub.goobi.forms.SpracheForm.java
/** * The function getSupportedLocales() returns a list of maps, each * representing one locale configured in the faces-config.xml file. Each of * the maps will contain the fields. id the locales ID String, e.g. fr? * or en_GB? displayLanguageSelf the name of the language in the language * itself, e.g. English?, Deutsch?, franais?, espaol?, ???, * ?, /*from w w w . j a va2 s . c o m*/ * * <p> * Its a good practice to identify a language in its own spelling, since * this will be most likely what a speaker of that language will recognize. * See also: http://www.cs.tut.fi/~jkorpela/flags.html Note that * capitalisation is subject to the respective language. If the language is * unknown, the id will be returned. displayLanguageTranslated the name of * the language in the currently selected language, e.g., if the current * language is English: English?, German?, French?, * </p> * * <p> * This is just a nice feature because the language names are provided by * Java; and its used in the mouse-over titles, so you can find out what * e.g. ? means, even if you dont have a clue of the glyphs used. If * no translations are available, this will fall back to English. selected * whether this is the current language * </p> * * <p> * This can be used for a sophisticated layout. * </p> * * @return a list of maps, each with the fields id?, displayName? and * selected? */ public List<Map<String, Object>> getSupportedLocales() { List<Map<String, Object>> result = new ArrayList<>(); Locale currentDisplayLanguage = FacesContext.getCurrentInstance().getViewRoot().getLocale(); @SuppressWarnings("unchecked") // It seems we have an old Faces API, Faces 2.1s getSupportedLocales() // returns Iterator<Locale> // TODO: Update JSF API Iterator<Locale> localesIterator = FacesContext.getCurrentInstance().getApplication().getSupportedLocales(); while (localesIterator.hasNext()) { Locale supportedLocale = localesIterator.next(); if (supportedLocale.getLanguage().length() > 0) { Map<String, Object> translation = new HashMap<>(); translation.put("id", supportedLocale.toString()); translation.put("displayLanguageSelf", supportedLocale.getDisplayLanguage(supportedLocale)); translation.put("displayLanguageTranslated", supportedLocale.getDisplayLanguage(currentDisplayLanguage)); translation.put("selected", Boolean.valueOf(supportedLocale.equals(currentDisplayLanguage))); result.add(translation); } } return result; }
From source file:org.kitodo.production.forms.LanguageForm.java
/** * The function getSupportedLocales() returns a list of maps, each * representing one locale configured in the faces-config.xml file. Each of * the maps will contain the fields. id the locales ID String, e.g. fr? * or en_GB? displayLanguageSelf the name of the language in the language * itself, e.g. English?, Deutsch?, franais?, espaol?, ???, * ?, //from w w w . j ava 2s.c om * * <p> * Its a good practice to identify a language in its own spelling, since * this will be most likely what a speaker of that language will recognize. * See also: http://www.cs.tut.fi/~jkorpela/flags.html Note that * capitalisation is subject to the respective language. If the language is * unknown, the id will be returned. displayLanguageTranslated the name of * the language in the currently selected language, e.g., if the current * language is English: English?, German?, French?, * </p> * * <p> * This is just a nice feature because the language names are provided by * Java; and its used in the mouse-over titles, so you can find out what * e.g. ? means, even if you dont have a clue of the glyphs used. If * no translations are available, this will fall back to English. selected * whether this is the current language * </p> * * <p> * This can be used for a sophisticated layout. * </p> * * @return a list of maps, each with the fields id?, displayName? and * selected? */ public List<Map<String, Object>> getSupportedLocales() { List<Map<String, Object>> result = new ArrayList<>(); Locale currentDisplayLanguage = FacesContext.getCurrentInstance().getViewRoot().getLocale(); // It seems we have an old Faces API, Faces 2.1s getSupportedLocales() // returns Iterator<Locale> // TODO: Update JSF API Iterator<Locale> localesIterator = FacesContext.getCurrentInstance().getApplication().getSupportedLocales(); while (localesIterator.hasNext()) { Locale supportedLocale = localesIterator.next(); if (supportedLocale.getLanguage().length() > 0) { Map<String, Object> translation = new HashMap<>(); translation.put("id", supportedLocale.toString()); translation.put("displayLanguageSelf", supportedLocale.getDisplayLanguage(supportedLocale)); translation.put("displayLanguageTranslated", supportedLocale.getDisplayLanguage(currentDisplayLanguage)); translation.put("selected", supportedLocale.equals(currentDisplayLanguage)); translation.put("flag", "javax.faces.resource/images/" + supportedLocale.toString() + ".svg.jsf"); result.add(translation); } } return result; }
From source file:com.github.lucapino.sheetmaker.parsers.mediainfo.MovieInfoImpl.java
String localizeLanguage(String language) { Locale langlocale = Locale.forLanguageTag(language); return StringUtils.capitalize(langlocale.getDisplayLanguage(langlocale)); }
From source file:com.hangum.tadpole.login.core.dialog.LoginDialog.java
/** * initialize cookie data// w w w . jav a 2 s . c o m */ private void initCookieData() { HttpServletRequest request = RWT.getRequest(); Cookie[] cookies = request.getCookies(); if (cookies != null) { int intCount = 0; for (Cookie cookie : cookies) { if (PublicTadpoleDefine.TDB_COOKIE_USER_ID.equals(cookie.getName())) { textEMail.setText(cookie.getValue()); intCount++; } else if (PublicTadpoleDefine.TDB_COOKIE_USER_SAVE_CKECK.equals(cookie.getName())) { btnCheckButton.setSelection(Boolean.parseBoolean(cookie.getValue())); intCount++; } else if (PublicTadpoleDefine.TDB_COOKIE_USER_LANGUAGE.equals(cookie.getName())) { Locale locale = Locale.forLanguageTag(cookie.getValue()); comboLanguage.setText(locale.getDisplayLanguage(locale)); changeUILocale(comboLanguage.getText()); intCount++; } if (intCount == 3) return; } } // ? ? . comboLanguage.select(0); changeUILocale(comboLanguage.getText()); }