Class LocaleUtils
java.lang.Object
com.inductiveautomation.ignition.common.i18n.LocaleUtils
Utility methods for working with
Locale objects, including sorting and parsing.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<Locale>A comparator that sorts Locales by display language, then by display country, case-insensitively. -
Method Summary
Modifier and TypeMethodDescriptiongetAvailableLocales(boolean andRegionalVariants) Returns the available locales, sorted.parseLocale(@Nullable String locale) Attempt to parse the given string into a locale - first, as a Java formatted locale, usingLocaleUtils.toLocale(String)- but if that fails, then by parsing it as a language tag.
-
Field Details
-
LOCALE_COMPARATOR
A comparator that sorts Locales by display language, then by display country, case-insensitively.
-
-
Method Details
-
getAvailableLocales
Returns the available locales, sorted.- Parameters:
andRegionalVariants- If true, regional variants (e.g., en_US) are included. If false, only base languages (e.g., en) are returned.- Returns:
- A sorted list of available locales.
-
parseLocale
Attempt to parse the given string into a locale - first, as a Java formatted locale, usingLocaleUtils.toLocale(String)- but if that fails, then by parsing it as a language tag. Will attempt to return an empty optional, rather than an invalid locale.
-