Class DefaultI18NProvider

java.lang.Object
com.vaadin.flow.i18n.DefaultI18NProvider
All Implemented Interfaces:
I18NProvider, Serializable

public class DefaultI18NProvider extends Object implements I18NProvider
Default i18n provider that will be initialized if custom I18NProvider is not available.
See Also:
  • Field Details

  • Constructor Details

    • DefaultI18NProvider

      public DefaultI18NProvider(List<Locale> providedLocales)
      Construct DefaultI18NProvider for a list of locales that we have translations for.
      Parameters:
      providedLocales - List of locales. The first locale should be the default locale.
  • Method Details

    • getProvidedLocales

      public List<Locale> 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 interface I18NProvider
      Returns:
      provided locales
    • getTranslation

      public String getTranslation(String key, Locale locale, Object... params)
      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 interface I18NProvider
      Parameters:
      key - translation key
      locale - locale to use
      params - parameters used in translation string
      Returns:
      translation for key if found