Promotion background
Easter Season IS HERE!
10% off limited time offer!
Ends in
00
H
00
M
00
S
limited time offer SAVE 10% NOW →
Packages com.phoenixplugins.sdk.api locales providers
com.phoenixplugins.sdk.api.locales.providers

Interface TranslationsProvider



  • public interface TranslationsProvider
    Provides translations for different locales and manages language resources.
    • Method Summary

      Modifier and Type Method and Description
      void changeTranslation(Locale locale)
      Changes the current translation locale.
      Locale getCurrentLocale()
      Gets the current locale being used for translations.
      Plugin getPlugin()
      Gets the plugin associated with this translations' provider.
      NavigableMap<String,String[]> getTranslations()
      Gets the translations map, which stores translation keys and their respective values.
      void loadDefaultResource(String resource)
      Loads a default translation resource into the system.
      void loadTranslations(String namespace, Function<Locale,TranslationFetcher> fetcher)
      Loads translations for the given namespace using a per-locale fetcher factory.
      String[] translate(Translation translation)
      Translates a given translatable object into the current locale.
      String[] translateOrNull(Translation translation)
      Translates a given translatable object into the current locale.
    • Method Detail

      • getPlugin

        Plugin getPlugin()
        Gets the plugin associated with this translations' provider.
        Returns:
        the Plugin instance
      • getCurrentLocale

        Locale getCurrentLocale()
        Gets the current locale being used for translations.
        Returns:
        the current Locale
      • getTranslations

        NavigableMap<String,String[]> getTranslations()
        Gets the translations map, which stores translation keys and their respective values.
        Returns:
        a NavigableMap containing translation entries
      • changeTranslation

        void changeTranslation(Locale locale)
                        throws Exception
        Changes the current translation locale.
        Parameters:
        locale - the new Locale to use
        Throws:
        Exception - if an error occurs while changing the translation
      • loadDefaultResource

        void loadDefaultResource(String resource)
                          throws Exception
        Loads a default translation resource into the system.
        Parameters:
        resource - the name of the resource to load
        Throws:
        Exception - if an error occurs while loading the resource
      • loadTranslations

        void loadTranslations(String namespace,
                              Function<Locale,TranslationFetcher> fetcher)
                       throws Exception
        Loads translations for the given namespace using a per-locale fetcher factory.

        Implementations should iterate the relevant locales and for each locale call fetcher.apply(locale) to obtain a TranslationFetcher for that locale. The returned fetcher should then be used to retrieve translations which implementations will store or merge under the provided namespace.

        Parameters:
        namespace - logical group or prefix under which fetched translations will be stored
        fetcher - a function that accepts a Locale and returns a TranslationFetcher for that locale
        Throws:
        Exception - if an error occurs while fetching, loading, or parsing translations
      • translate

        String[] translate(Translation translation)
        Translates a given translatable object into the current locale.
        Parameters:
        translation - the Translation to translate
        Returns:
        an array of translated strings
      • translateOrNull

        String[] translateOrNull(Translation translation)
        Translates a given translatable object into the current locale.
        Parameters:
        translation - the Translation to translate
        Returns:
        an array of translated strings
Last updated about 5 hours ago
My Cart (0 items)

Oops... looks like the spiders padded through here

Add products to your cart and remove them from here Lets buy
This site uses cookies to personalize content, enhance your experience. By continuing, you agree to our cookie use. Learn more