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) ConstructDefaultI18NProviderfor a list of locales that we have translations for.DefaultI18NProvider(List<Locale> providedLocales, ClassLoader classLoader) ConstructDefaultI18NProviderfor a list of locales that we have translations for. -
Method Summary
Modifier and TypeMethodDescriptiongetAllTranslations(Locale locale) Retrieves all available translations.Get 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, waitMethods inherited from interface com.vaadin.flow.i18n.I18NProvider
getDefaultLocale, getTranslation, getTranslations
-
Field Details
-
BUNDLE_FOLDER
- See Also:
-
BUNDLE_FILENAME
- See Also:
-
BUNDLE_PREFIX
- See Also:
-
-
Constructor Details
-
DefaultI18NProvider
ConstructDefaultI18NProviderfor a list of locales that we have translations for.- Parameters:
providedLocales- List of locales. The first locale should be the default locale.
-
DefaultI18NProvider
ConstructDefaultI18NProviderfor 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:I18NProviderGet the locales that we have translations for. The first locale should be the default locale.- Specified by:
getProvidedLocalesin interfaceI18NProvider- Returns:
- provided locales
-
getTranslation
Description copied from interface:I18NProviderGet 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:
getTranslationin interfaceI18NProvider- Parameters:
key- translation keylocale- locale to useparams- parameters used in translation string- Returns:
- translation for key if found
-
getAllTranslations
Description copied from interface:I18NProviderRetrieves all available translations. This is currently used only by Hilla in development mode.- Specified by:
getAllTranslationsin interfaceI18NProvider- Parameters:
locale- locale to use- Returns:
- a map of all available translations (the default implementation just returns an empty map)
-