Package com.vaadin.flow.i18n
Class DefaultI18NProvider
java.lang.Object
com.vaadin.flow.i18n.DefaultI18NProvider
- All Implemented Interfaces:
I18NProvider
,Serializable
Default i18n provider that will be initialized if custom
I18NProvider
is not available.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultI18NProvider
(List<Locale> providedLocales) ConstructDefaultI18NProvider
for a list of locales that we have translations for.DefaultI18NProvider
(List<Locale> providedLocales, ClassLoader classLoader) ConstructDefaultI18NProvider
for a list of locales that we have translations for. -
Method Summary
Modifier and TypeMethodDescriptionGet the locales that we have translations for.getTranslation
(String key, Locale locale, Object... params) Get the translation for key with given locale.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.i18n.I18NProvider
getTranslation
-
Field Details
-
BUNDLE_FOLDER
- See Also:
-
BUNDLE_FILENAME
- See Also:
-
BUNDLE_PREFIX
- See Also:
-
-
Constructor Details
-
DefaultI18NProvider
ConstructDefaultI18NProvider
for a list of locales that we have translations for.- Parameters:
providedLocales
- List of locales. The first locale should be the default locale.
-
DefaultI18NProvider
ConstructDefaultI18NProvider
for a list of locales that we have translations for. Enables giving a specific classloader if needed.- Parameters:
providedLocales
- List of locales. The first locale should be the default locale.classLoader
- ClassLoader to use for loading translation bundles.
-
-
Method Details
-
getProvidedLocales
Description copied from interface:I18NProvider
Get the locales that we have translations for. The first locale should be the default locale.- Specified by:
getProvidedLocales
in interfaceI18NProvider
- Returns:
- provided locales
-
getTranslation
Description copied from interface:I18NProvider
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}!'
- Specified by:
getTranslation
in interfaceI18NProvider
- Parameters:
key
- translation keylocale
- locale to useparams
- parameters used in translation string- Returns:
- translation for key if found
-