/** * Checks if the given {@link Locale} is in the available locales on the current jdk. * * @param locale * the locale to check * @return true, if successful */ public static boolean contains(final Locale locale) { final List<Locale> availableLocales = getAvailableLocales(); final boolean exists = availableLocales.contains(locale); return exists; }
/** * Gets the display country name from the given country code in the given {@link Locale}. * * @param countryCode * the country code * @param inLocale * The locale for which to retrieve the display country * @return the country name */ public static String getCountryName(String countryCode, Locale inLocale) { return getCountryName(countryCode, inLocale, countryCode); }
/** * Gets the locale file name suffix that has the format 'language_COUNTRY_variant' for instance * 'de_DE' for the Locale.GERMANY. * * @param locale * the locale * @return the locale name */ public static String getLocaleFilenameSuffix(final Locale locale) { return getLocaleFileSuffix(locale, true, true, false); }
/** * {@inheritDoc} */ @Override public List<Resourcebundles> findResourceBundles(BundleApplications owner, String baseName, Locale locale, String key) { return find(owner, baseName, LocaleExtensions.getLocaleFilenameSuffix(locale), key, null); }
@Override public LanguageLocales find(Locale locale) { return find(LocaleExtensions.getLocaleFilenameSuffix(locale)); }
/** * {@inheritDoc} */ @Override public List<Resourcebundles> findResourceBundles(BundleApplications owner, String baseName, Locale locale) { return find(owner, baseName, LocaleExtensions.getLocaleFilenameSuffix(locale), null, null); }
/** * Gets the locale name for instance 'de_DE' for the Locale.GERMANY. * * @param locale * the locale * @return the locale name */ public static String getLocaleName(final Locale locale) { return getLocaleFileSuffix(locale, true, true, false); }
@Override public BundleNames find(final BundleApplications owner, final String baseName, final Locale locale) { return ListExtensions .getFirst(find(owner, baseName, LocaleExtensions.getLocaleFilenameSuffix(locale))); }
/** * Gets the locale file name suffix for instance '_de_DE' for the Locale.GERMANY. * * @param locale * the locale * @param withCountry * the with country * @return the locale file suffix */ public static String getLocaleFileSuffix(final Locale locale, final boolean withCountry) { return getLocaleFileSuffix(locale, withCountry, false); }
/** * Factory method for create a new {@link LanguageLocales}. * * @param locale * the {@link Locale} object. * * @return the new {@link LanguageLocales} */ public LanguageLocales newLanguageLocales(final Locale locale) { final LanguageLocales languageLocales = LanguageLocales.builder() .locale(LocaleExtensions.getLocaleFilenameSuffix(locale)).build(); return languageLocales; }
/** * Gets the locale file name suffix for instance '_de_DE' for the Locale.GERMANY. * * @param locale * the locale * @param withCountry * with country * @param withVariant * with variant * @return the locale file suffix */ public static String getLocaleFileSuffix(final Locale locale, final boolean withCountry, final boolean withVariant) { return getLocaleFileSuffix(locale, withCountry, withVariant, true); }
@Override public Resourcebundle find(final BundleApplication bundleApplication, final String baseName, final Locale locale, final String key) { final BundleApplications owner = resourcebundlesService.find(bundleApplication.getName()); final List<Resourcebundles> list = resourcebundlesService.find(owner, baseName, LocaleExtensions.getLocaleFilenameSuffix(locale), key, null); final Resourcebundles first = ListExtensions.getFirst(list); if (first != null) { return getMapper().toDomainObject(first); } return null; }