Packages 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
    Description
    void
    Changes the current translation locale.
    Gets the current locale being used for translations.
    Gets the plugin associated with this translations' provider.
    NavigableMap<String,String[]>
    Gets the translations map, which stores translation keys and their respective values.
    void
    loadDefaultResource(String resource)
    Loads a default translation resource into the system using the provider's current locale.
    void
    loadDefaultResource(String resource, Locale locale)
    Loads a default translation resource into the system using an explicit locale.
    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[]
    Translates a given translatable object into the current locale.
  • Method Details

    • 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 using the provider's current locale.
      Parameters:
      resource - the name of the resource to load
      Throws:
      Exception - if an error occurs while loading the resource
    • loadDefaultResource

      void loadDefaultResource(String resource, Locale locale) throws Exception
      Loads a default translation resource into the system using an explicit locale. Useful for SDK-internal base resources that only ship in one language.
      Parameters:
      resource - the name of the resource to load
      locale - the locale to use when reading the resource
      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 10 days ago
My Cart
Spider

Your cart is empty

Looks like the spiders padded through here. Pick a plugin and it will show up here. Continue shopping