/** * Resolves a {@link Locale} objects from the given language code. * * @param languageCode * the language code * @return the found {@link Locale} objects or an empty list if nothing found */ public static List<Locale> getLocales(@NonNull String languageCode) { List<Locale> locales = ListFactory.newArrayList(); getAvailableLocales().forEach(locale -> { if (locale.getLanguage().equals(languageCode)) { locales.add(locale); } }); return locales; }
/** * Resolves a {@link Locale} from the given country code. * * @param countryCode * the country code * @return the found {@link Locale} or null if not found */ public static Locale getLocale(@NonNull String countryCode) { List<Locale> locales = ListFactory.newArrayList(); getAvailableLocales().forEach(locale -> { if (locale.getCountry().equals(countryCode)) { locales.add(locale); } }); return ListExtensions.getFirst(locales); }