com.vaadin.flow.i18n.
Interface I18NProvider
All Superinterfaces:
All Known Implementing Classes:
I18N provider interface for internationalization usage.
Since:
1.0
-
Method Summary
Modifier and TypeMethodDescriptionGet the locales that we have translations for.
default String
getTranslation
(Object key, Locale locale, Object... params) Get the translation for key with given locale.
getTranslation
(String key, Locale locale, Object... params) Get the translation for key with given locale.
static String
Get the translation for key via
I18NProvider
instance retrieved from the current VaadinService.static String
Get the translation for key with given locale via
I18NProvider
instance retrieved from the current VaadinService.
-
Method Details
-
getProvidedLocales
Get the locales that we have translations for. The first locale should be the default locale.
Returns:
provided locales
-
getTranslation
Get the translation for key with given locale.
Note! For usability and catching missing translations implementation should never return a null, but an exception string e.g. '!{key}!'
Parameters:
key
- translation keylocale
- locale to useparams
- parameters used in translation stringReturns:
translation for key if found
-
getTranslation
Get the translation for key with given locale.
Note! For usability and catching missing translations implementation should never return a null, but an exception string e.g. '!{key}!'
Parameters:
key
- translation keylocale
- locale to useparams
- parameters used in translation stringReturns:
translation for key if found
-
translate
Get the translation for key via
I18NProvider
instance retrieved from the current VaadinService. Uses the current UI locale, or if not available, then the default locale.Parameters:
key
- translation keyparams
- parameters used in translation stringReturns:
translation for key if found
Throws:
IllegalStateException
- thrown if no I18NProvider found from the VaadinService -
translate
Get the translation for key with given locale via
I18NProvider
instance retrieved from the current VaadinService.Parameters:
locale
- locale to usekey
- translation keyparams
- parameters used in translation stringReturns:
translation for key if found
Throws:
IllegalStateException
- thrown if no I18NProvider found from the VaadinService
-