List of usage examples for java.util Locale getDisplayName
public final String getDisplayName()
From source file:org.wso2.carbon.email.mgt.config.EmailConfigTransformer.java
public static EmailTemplateDTO[] transform(Properties props) throws I18nMgtEmailConfigException { List<EmailTemplateDTO> emailTemplates = new ArrayList<EmailTemplateDTO>(); if (log.isDebugEnabled()) { log.debug("Transforming Properties to EmailTemplateDTO[]"); }//w w w .j av a 2s . co m Set<String> keySet = props.stringPropertyNames(); String emailTemplateLanguage; String emailTemplateDisplayType; String emailContentType; for (String key : keySet) { EmailTemplateDTO template = new EmailTemplateDTO(); String[] emailTemplateKeyArray = key.split("\\|"); template.setName(emailTemplateKeyArray[0]); emailTemplateDisplayType = emailTemplateKeyArray[1]; emailContentType = emailTemplateKeyArray[2]; // Retrieves the content of each email template. String[] emailTemplateContent = props.getProperty(key).split("\\|"); if (emailTemplateContent.length > 3) { throw new I18nMgtEmailConfigException("Cannot have | character in the template"); } String[] emailTypeKeyArray = emailTemplateKeyArray[0].split("\\."); String[] emailLocalCodeArray = emailTypeKeyArray[1].split("_"); Locale localeObject = new Locale(emailLocalCodeArray[0], emailLocalCodeArray[1]); emailTemplateLanguage = localeObject.getDisplayName(); String subject = emailTemplateContent[0]; String body = emailTemplateContent[1]; String footer = emailTemplateContent[2]; if (log.isDebugEnabled()) { log.debug("Template info - name: " + key + " locale: " + emailTemplateLanguage + " subject: " + subject + " body: " + body + " footer: " + footer + " displayName:" + emailTemplateDisplayType); } template.setLocale(emailTemplateLanguage); template.setSubject(subject); template.setBody(body); template.setFooter(footer); template.setDisplayName(emailTemplateDisplayType); template.setEmailContentType(emailContentType); emailTemplates.add(template); } return emailTemplates.toArray(new EmailTemplateDTO[emailTemplates.size()]); }
From source file:org.sakaiproject.jsf.util.LocaleUtil.java
public static String getLocalizedString(FacesContext context, String bundleName, String key) { String localized = null;/* w ww . j a v a 2s .c om*/ Locale locale = getLocale(context); ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale); if (log.isDebugEnabled()) log.debug("getLocalizedString; locale=" + locale.getDisplayName() + ", bundleName=" + bundleName + ", rb=" + rb.getLocale() + ", rb getCountry()=" + rb.getLocale().getCountry()); localized = rb.getString(key); return localized; }
From source file:edu.ku.brc.af.core.SchemaI18NService.java
/** * Only Loads the Locales with empty Country and Variant */// w w w .ja va2s. co m public static void initializeLocales() { SchemaI18NService srv = getInstance(); if (srv != null) { Vector<Locale> locs = srv.getLocales(); if (locs.size() == 0) { for (Locale locale : Locale.getAvailableLocales()) { if (StringUtils.isNotEmpty(locale.getCountry())) { locs.add(locale); } } Collections.sort(locs, new Comparator<Locale>() { public int compare(Locale o1, Locale o2) { return o1.getDisplayName().compareTo(o2.getDisplayName()); } }); } } }
From source file:com.hichinaschool.flashcards.anki.ReadText.java
public static void textToSpeech(String text, long did, int ord, int qa) { mTextToSpeak = text;//from w w w .j a v a2 s .c o m mQuestionAnswer = qa; mDid = did; mOrd = ord; String language = getLanguage(mDid, mOrd, mQuestionAnswer); if (availableTtsLocales.isEmpty()) { Locale[] systemLocales = Locale.getAvailableLocales(); for (Locale loc : systemLocales) { if (mTts.isLanguageAvailable(loc) == TextToSpeech.LANG_COUNTRY_AVAILABLE) { availableTtsLocales.add(new String[] { loc.getISO3Language(), loc.getDisplayName() }); } } } // Check, if stored language is available for (int i = 0; i < availableTtsLocales.size(); i++) { if (language.equals(NO_TTS)) { return; } else if (language.equals(availableTtsLocales.get(i)[0])) { speak(mTextToSpeak, language); return; } } // Otherwise ask Resources res = mReviewer.getResources(); StyledDialog.Builder builder = new StyledDialog.Builder(mReviewer); if (availableTtsLocales.size() == 0) { builder.setTitle(res.getString(R.string.no_tts_available_title)); builder.setMessage(res.getString(R.string.no_tts_available_message)); builder.setIcon(R.drawable.ic_dialog_alert); builder.setPositiveButton(res.getString(R.string.ok), null); } else { ArrayList<CharSequence> dialogItems = new ArrayList<CharSequence>(); final ArrayList<String> dialogIds = new ArrayList<String>(); builder.setTitle(R.string.select_locale_title); // Add option: "no tts" dialogItems.add(res.getString(R.string.tts_no_tts)); dialogIds.add(NO_TTS); for (int i = 0; i < availableTtsLocales.size(); i++) { dialogItems.add(availableTtsLocales.get(i)[1]); dialogIds.add(availableTtsLocales.get(i)[0]); } String[] items = new String[dialogItems.size()]; dialogItems.toArray(items); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { MetaDB.storeLanguage(mReviewer, mDid, mOrd, mQuestionAnswer, dialogIds.get(which)); speak(mTextToSpeak, dialogIds.get(which)); } }); } builder.create().show(); }
From source file:org.jahia.utils.LanguageCodeConverters.java
public static List<Locale> getAvailableBundleLocales(String resourceBundleName, Locale defaultLocale) { final List<Locale> availableBundleLocales = new LinkedList<Locale>(); // first let's add the default locale if it exists. if (defaultLocale != null && ResourceBundle.getBundle(resourceBundleName, defaultLocale) != null) { availableBundleLocales.add(defaultLocale); }/*from w w w . jav a 2 s .co m*/ for (Locale locale : getAvailableLocales()) { if (!StringUtils.isEmpty(locale.getDisplayName())) { // Avoid "default/system" empty locale ResourceBundle res = ResourceBundle.getBundle(resourceBundleName, locale); if (res != null && res.getLocale().equals(locale) && (defaultLocale == null || !locale.equals(defaultLocale))) { availableBundleLocales.add(locale); } } } return availableBundleLocales; }
From source file:net.java.sen.StringTagger.java
/** * Obtain StringTagger instance for specified locale. * /*w w w. j ava 2 s . c o m*/ * @deprecated use instead of StringTagger#getinstance(String senConfig) * @param locale * Locale to generate morphological analyzer. */ public static StringTagger getInstance(Locale locale) throws IOException, IllegalArgumentException { if (locale.equals(Locale.JAPANESE)) { return getInstance(); } else { throw new IllegalArgumentException("Locale '" + locale.getDisplayName() + "' isn't supported."); } }
From source file:org.springforpro.chptr5.pe.PropertyEditorBean.java
public void setLocale(Locale locale) { System.out.println("Setting locale value = " + locale.getDisplayName()); this.locale = locale; }
From source file:IteratorTest.java
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean hasFocus) { Locale locale = (Locale) (value); return super.getListCellRendererComponent(list, locale.getDisplayName(), index, isSelected, hasFocus); }
From source file:Deet.java
private boolean testDeet(Locale l) { // getISO3Language() may throw a MissingResourceException out.format("Locale = %s, ISO Language Code = %s%n", l.getDisplayName(), l.getISO3Language()); return true;/*ww w .j av a 2 s .c om*/ }
From source file:org.vosao.service.front.impl.LoginServiceImpl.java
@Override public ServiceResponse setLanguage(String language) { Locale locale = LanguageFilter.getLocale(language); logger.info("Locale " + locale.getDisplayName()); VosaoContext.getInstance().setLocale(locale); VosaoContext.getInstance().getSession().setLocale(locale); return ServiceResponse.createSuccessResponse(Messages.get("success")); }