Interface I18NProvider

All Superinterfaces:
Serializable
All Known Implementing Classes:
DefaultI18NProvider

public interface I18NProvider extends Serializable
I18N provider interface for internationalization usage.
Since:
1.0
  • Method Details

    • getProvidedLocales

      List<Locale> getProvidedLocales()
      Get the locales that we have translations for. The first locale should be the default locale.
      Returns:
      provided locales
    • getTranslation

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

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

      static String translate(String key, Object... params)
      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 key
      params - parameters used in translation string
      Returns:
      translation for key if found
      Throws:
      IllegalStateException - thrown if no I18NProvider found from the VaadinService
    • translate

      static String translate(Locale locale, String key, Object... params)
      Get the translation for key with given locale via I18NProvider instance retrieved from the current VaadinService.
      Parameters:
      locale - locale to use
      key - translation key
      params - parameters used in translation string
      Returns:
      translation for key if found
      Throws:
      IllegalStateException - thrown if no I18NProvider found from the VaadinService