List of usage examples for java.util Locale getDisplayLanguage
public String getDisplayLanguage(Locale inLocale)
From source file:Main.java
public static void main(String[] args) { Locale locale = new Locale("ENGLISH", "US"); System.out.println("Locale:" + locale); // print language for another locale - result is based on inLocale System.out.println("Language:" + locale.getDisplayLanguage(new Locale("GERMANY", "GERMAN"))); }
From source file:Main.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:com.hangum.tadpole.commons.util.RequestInfoUtils.java
/** * Return request locale/*from w w w. j av a2s . c om*/ * * @return */ public static String getDisplayLocale() { HttpServletRequest request = RWT.getRequest(); Locale locale = request.getLocale(); return locale.getDisplayLanguage(Locale.ENGLISH); }
From source file:edu.jhuapl.openessence.i18n.SupportedLocale.java
/** * @param messageSource to translate displayLanguage *///from w w w . jav a 2 s . c o m public static SupportedLocale fromLocale(Locale locale, MessageSource messageSource) { SupportedLocale sl = new SupportedLocale(); sl.setCode(locale.toString()); // display language in target locale, i.e. "espaol" instead of "Spanish" String defaultDisplayLanguage = locale.getDisplayLanguage(locale); // Java doesn't have every language display name in every language // (e.g. doesn't have "Khmer" in Khmer), so use message bundle as fallback String lang = messageSource.getMessage("language." + locale.getLanguage(), null, defaultDisplayLanguage, locale); sl.setDisplayLanguage(lang); return sl; }
From source file:com.cyclopsgroup.tornado.ui.view.user.UserProfile.java
/** * Override method execute in class UserProfile * * @see com.cyclopsgroup.waterview.Module#execute(com.cyclopsgroup.waterview.RuntimeData, com.cyclopsgroup.waterview.Context) *///w ww . j a v a2 s. co m public void execute(RuntimeData data, Context context) throws Exception { RuntimeUser user = RuntimeUser.getInstance(data); PersistenceManager persist = (PersistenceManager) lookup(PersistenceManager.ROLE); User u = (User) persist.load(User.class, user.getId()); context.put("userObject", u); TreeMap languages = new TreeMap(); TreeMap countries = new TreeMap(); Locale[] availableLocales = Locale.getAvailableLocales(); for (int i = 0; i < availableLocales.length; i++) { Locale locale = availableLocales[i]; DefaultSelectOption lang = new DefaultSelectOption(locale.getLanguage(), locale.getDisplayLanguage(data.getLocale()) + '(' + locale.getLanguage() + ')'); languages.put(locale.getLanguage(), lang); if (StringUtils.isNotEmpty(locale.getCountry())) { DefaultSelectOption cout = new DefaultSelectOption(locale.getCountry(), locale.getDisplayCountry(data.getLocale()) + '(' + locale.getCountry() + ')'); countries.put(locale.getCountry(), cout); } } context.put("countries", countries.values()); context.put("languages", languages.values()); }
From source file:org.sisto.jeeplate.jsf.Oracle.java
public Map<String, String> localizedLanguages() { Map<String, String> localized = new TreeMap<>(); Locale viewLocale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); this.languages.keySet().stream().forEach((key) -> { String val = (String) this.languages.get(key); Locale loc = new Locale(val); String display = loc.getDisplayLanguage(viewLocale); if (display.length() > 0) { localized.put(display, key); }/*www .j a va2s.co m*/ }); return localized; }
From source file:com.doculibre.constellio.wicket.components.locale.LocaleNameLabel.java
public LocaleNameLabel(String id, final Locale locale, final boolean addParenthesis) { super(id);/*from w ww. java 2s . c o m*/ setModel(new LoadableDetachableModel() { @Override protected Object load() { String localeName = StringUtils.capitalize(locale.getDisplayLanguage(getLocale())); if (addParenthesis) { localeName = "(" + localeName + ")"; } return localeName; } }); }
From source file:org.kitodo.production.forms.LanguageForm.java
/** * Get the name of the current language. * @return the name of the language as String *///from w ww . j av a 2 s .c o m public String getCurrentLanguageTranslated() { Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); return locale.getDisplayLanguage(locale); }
From source file:org.obiba.onyx.quartz.editor.locale.LabelsPanel.java
/** * @param id/* w ww . ja va 2s . c om*/ * @param model * @param elementModel * @param feedbackPanel * @param feedbackWindow * @param tooltips * @param visibleStates Map with label element as key and a boolean set to true to show it or false to hide it. * Set to null to display all labels. */ public LabelsPanel(String id, IModel<LocaleProperties> model, IModel<? extends IQuestionnaireElement> elementModel, FeedbackPanel feedbackPanel, FeedbackWindow feedbackWindow, Map<String, IModel<String>> tooltips, final Map<String, Boolean> visibleStates) { super(id, model); this.elementModel = elementModel; this.tooltips = tooltips; setOutputMarkupId(true); add(CSSPackageResource.getHeaderContribution(LabelsPanel.class, "LabelsPanel.css")); LocaleProperties localeProperties = (LocaleProperties) getDefaultModelObject(); final ListMultimap<Locale, KeyValue> elementLabels = localeProperties .getElementLabels(elementModel.getObject()); Locale userLocale = Session.get().getLocale(); List<ITab> tabs = new ArrayList<ITab>(); for (final Locale locale : localeProperties.getLocales()) { AbstractTab tab = new AbstractTab(new Model<String>(locale.getDisplayLanguage(userLocale))) { @Override public Panel getPanel(String panelId) { return new InputPanel(panelId, new ListModel<KeyValue>(elementLabels.get(locale)), visibleStates); } }; ITab panelCachingTab = new PanelCachingTab(tab); tabs.add(panelCachingTab); tabByLocale.put(locale, panelCachingTab); } tabbedPanel = new AjaxSubmitTabbedPanel("tabs", feedbackPanel, feedbackWindow, tabs); tabbedPanel.setVisible(tabs.size() > 0); tabsContainer = new WebMarkupContainer("tabsContainer"); tabsContainer.setOutputMarkupId(true); tabsContainer.add(tabbedPanel); Form<LocaleProperties> form = new Form<LocaleProperties>("form", model); form.setMultiPart(false); form.setOutputMarkupId(true); form.add(tabsContainer); add(form); }
From source file:im.vector.VectorApp.java
/** * Convert a locale to a string//from w ww.j a v a 2 s .co m * * @param locale the locale to convert * @return the string */ public static String localeToLocalisedString(Locale locale) { String res = locale.getDisplayLanguage(locale); if (!TextUtils.isEmpty(locale.getDisplayCountry(locale))) { res += " (" + locale.getDisplayCountry(locale) + ")"; } return res; }