List of usage examples for java.util Locale equals
@Override public boolean equals(Object obj)
From source file:com.carlomicieli.jtrains.value.objects.LocalizedField.java
/** * Returns {@code true} if the provided {@code Locale} is the default for * the current instance.//from ww w . j ava 2 s .c om * * @param locale the {@code Locale} * @return {@code true} if the provided {@code Locale} is the default for * the current instance. */ public static boolean isDefaultLocale(Locale locale) { return locale.equals(AppGlobals.DEFAULT_LOCALE); }
From source file:adalid.commons.bundles.Bundle.java
/** * @param newLocale the locale to set//from www . j a va 2s . c om */ public static void setLocale(Locale newLocale) { ResourceBundle prevResourceBundle = resourceBundle; if (newLocale == null) { locale = Locale.getDefault(); resourceBundle = defaultResourceBundle; } else if (newLocale.equals(locale)) { } else { locale = newLocale; try { resourceBundle = ResourceBundle.getBundle(BASE_NAME, locale); } catch (MissingResourceException e) { resourceBundle = defaultResourceBundle; } } if (resourceBundle.equals(prevResourceBundle)) { } else { linguist = getLinguist(resourceBundle); } }
From source file:com.cburch.logisim.util.LocaleManager.java
public static void setLocale(Locale loc) { Locale cur = getLocale();/* ww w.j av a2s . co m*/ if (!loc.equals(cur)) { Locale[] opts = LocaleString.getUtilLocaleManager().getLocaleOptions(); Locale select = null; Locale backup = null; String locLang = loc.getLanguage(); for (Locale opt : opts) { if (select == null && opt.equals(loc)) { select = opt; } if (backup == null && opt.getLanguage().equals(locLang)) { backup = opt; } } if (select == null) { if (backup == null) { select = new Locale("en"); } else { select = backup; } } curLocale = select; Locale.setDefault(select); for (LocaleManager man : managers) { man.loadDefault(); } repl = replaceAccents ? fetchReplaceAccents() : null; fireLocaleChanged(); } }
From source file:com.edgenius.core.Global.java
/** * @param locale only include language part but not country info * @return//from w w w . j a v a 2 s. c om */ public static boolean isLanguage(Locale locale) { return locale.equals(new Locale(Global.DefaultLanguage)); }
From source file:com.hypersocket.i18n.I18N.java
private static File getOverrideFile(Locale locale, String bundle) { if (locale.equals(Locale.ENGLISH)) { return new File(overideDirector, bundle + ".properties"); } else {/*www . j a va2 s.c o m*/ return new File(overideDirector, bundle + "_" + locale.toString() + ".properties"); } }
From source file:utybo.branchingstorytree.swing.OpenBST.java
/** * Load the default language (which should be English) as well as the user's * language. We avoid loading all the language files to avoid having our RAM * usage blowing up.//from w w w . j av a2 s .c o m * * @param userCustomLanguage * The language to use in the application, which must be one * defined in the langs.json file */ private static void loadLang(final String userCustomLanguage) { final Map<String, String> languages = new Gson() .fromJson( new InputStreamReader(OpenBST.class.getResourceAsStream( "/utybo/branchingstorytree/swing/lang/langs.json"), StandardCharsets.UTF_8), new TypeToken<Map<String, String>>() { }.getType()); try { Lang.loadTranslationsFromFile(Lang.getDefaultLanguage(), OpenBST.class .getResourceAsStream("/utybo/branchingstorytree/swing/lang/" + languages.get("default"))); } catch (final Exception e) { LOG.warn("Exception while loading language file : " + languages.get("default"), e); } if (userCustomLanguage != null) { Lang.setSelectedLanguage(new Locale(userCustomLanguage)); } final Locale userLanguage = Lang.getSelectedLanguage(); languages.forEach((k, v) -> { if (userLanguage.equals(new Locale(k)) && !v.equals(languages.get("default"))) { try { Lang.loadTranslationsFromFile(userLanguage, OpenBST.class.getResourceAsStream("/utybo/branchingstorytree/swing/lang/" + v)); } catch (final Exception e) { LOG.warn("Exception while loading language file : " + v, e); } } }); }
From source file:net.java.sen.StringTagger.java
/** * Obtain StringTagger instance for specified locale. * /* w w w. ja va2 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:com.google.android.mms.transaction.HttpUtils.java
/** * Return the Accept-Language header. Use the current locale plus * US if we are in a different locale than US. *///w w w . j a va 2s . c o m private static String getHttpAcceptLanguage() { Locale locale = Locale.getDefault(); StringBuilder builder = new StringBuilder(); addLocaleToHttpAcceptLanguage(builder, locale); if (!locale.equals(Locale.US)) { if (builder.length() > 0) { builder.append(", "); } addLocaleToHttpAcceptLanguage(builder, Locale.US); } return builder.toString(); }
From source file:marytts.modules.ModuleRegistry.java
/** * Lookup a list of modules for the given combination of type, locale and voice. * A given lookup will return a list of modules accepting the datatype as input, * ordered by specificity so that the most specific modules come first. * For each output type produced by modules, there will be only one module * producing that type, namely the most specific one found. * Specificity is ordered as follows:/*from www.j a v a 2s. c o m*/ * 1. most specific is the full combination of datatype, locale and voice; * 2. the combination of datatype, language-only locale and voice (i.e., for requested locale "en-US" will find modules with locale "en"); * 3. the combination of datatype and locale, ignoring voice; * 4. the combination of datatype and language-only locale, ignoring voice; * 5. least specific is the datatype, ignoring locale and voice. * @param type the type of input data * @param locale the locale * @param voice the voice to use. * @return a list of mary modules accepting the datatype and suitable for * the given locale and voice, ordered by their specificity, * or an empty list if there is no suitable module. * @throws IllegalStateException if called when registration is not yet complete. */ @SuppressWarnings("unchecked") private static List<MaryModule> get(MaryDataType type, Locale locale, Voice voice) throws IllegalStateException { if (!registrationComplete) throw new IllegalStateException("Cannot inquire about modules while registration is ongoing"); LinkedHashMap<MaryDataType, MaryModule> results = new LinkedHashMap<MaryDataType, MaryModule>(); // First, get all results: List<List<MaryModule>> listOfLists = new LinkedList<List<MaryModule>>(); listOfLists.add((List<MaryModule>) mkm.get(type, locale, voice)); Locale langOnly = locale != null ? new Locale(locale.getLanguage()) : null; boolean haveCountry = langOnly == null ? false : !langOnly.equals(locale); if (haveCountry) { listOfLists.add((List<MaryModule>) mkm.get(type, langOnly, voice)); } listOfLists.add((List<MaryModule>) mkm.get(type, locale, null)); if (haveCountry) { listOfLists.add((List<MaryModule>) mkm.get(type, langOnly, null)); } listOfLists.add((List<MaryModule>) mkm.get(type, null, null)); // Now, for each mary output type, keep only the most specific module, // and return the list ordered by the specificity of modules (most specific first): for (List<MaryModule> list : listOfLists) { if (list != null) { for (MaryModule m : list) { if (!results.containsKey(m.outputType())) results.put(m.outputType(), m); } } } List<MaryModule> returnList = new LinkedList<MaryModule>(); for (MaryDataType t : results.keySet()) { returnList.add(results.get(t)); } return returnList; }
From source file:com.chen.mail.browse.SendersView.java
static String getMe(Context context) { final Resources resources = context.getResources(); final Locale locale = resources.getConfiguration().locale; if (sMeString == null || !locale.equals(sMeStringLocale)) { sMeString = resources.getString(R.string.me_subject_pronun); sMeStringLocale = locale;/*from w w w.ja va 2 s . co m*/ } return sMeString; }