Package com.vaadin.flow.internal
Class LocaleUtil
java.lang.Object
com.vaadin.flow.internal.LocaleUtil
Utility class for locale handling.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptiongetExactLocaleMatch
(VaadinRequest request, List<Locale> providedLocales) Get the exact locale match for the given request in the provided locales.static Optional<I18NProvider>
Get the I18nProvider from the current VaadinService.static Locale
Get the locale from the current UI or from the I18NProvider from the current VaadinService.static Locale
getLocale
(Supplier<Optional<I18NProvider>> i18NProvider) Get the locale from the current UI or from the given I18NProvider.getLocaleMatchByLanguage
(VaadinRequest request, List<Locale> providedLocales) Get the locale matching the language of the request locale in the provided locales.
-
Method Details
-
getExactLocaleMatch
public static Optional<Locale> getExactLocaleMatch(VaadinRequest request, List<Locale> providedLocales) Get the exact locale match for the given request in the provided locales.- Parameters:
request
- request to get locale forprovidedLocales
- application provided locales- Returns:
- found locale or null if no exact matches
-
getLocaleMatchByLanguage
public static Optional<Locale> getLocaleMatchByLanguage(VaadinRequest request, List<Locale> providedLocales) Get the locale matching the language of the request locale in the provided locales.- Parameters:
request
- request to get locale forprovidedLocales
- application provided locales- Returns:
- found locale or null if no matches by language
-
getI18NProvider
Get the I18nProvider from the current VaadinService.- Returns:
- the optional value of I18nProvider
-
getLocale
Get the locale from the current UI or from the given I18NProvider.-> If UI is not null, then it is used to get the locale, -> if UI is null, then the I18NProvider providedLocales first match will be returned, -> if I18NProvider is null, then default locale is returned.
- Parameters:
i18NProvider
- - supplier for the i18n provider- Returns:
- the locale for the UI
-
getLocale
Get the locale from the current UI or from the I18NProvider from the current VaadinService.-> If UI is not null, then it is used to get the locale, -> if UI is null, then the I18NProvider providedLocales first match will be returned, -> if I18NProvider is null, then default locale is returned.
- Returns:
- the locale for the UI
-