Interface BundleTranslationSource

All Superinterfaces:
TranslationSource

public interface BundleTranslationSource extends TranslationSource
A translation source that can register translation from resource bundles and other sources.
  • Method Details

    • create

      static BundleTranslationSource create(Locale defaultLocale)
      Creates a new BundleTranslationSource instance.
      Parameters:
      defaultLocale - the default locale of the translation source
      Returns:
      a new BundleTranslationSource instance
    • registerAll

      default void registerAll(Locale locale, Map<String,Translation> translations)
      Registers a map of translations.
      Parameters:
      locale - the locale of the translations
      translations - the map
      Throws:
      IllegalArgumentException - if a key is already registered
    • registerAll

      default void registerAll(ResourceBundle bundle)
      Registers the entries of the given resource bundle as text translations.
      Parameters:
      bundle - the resource bundle
    • registerAll

      default void registerAll(ResourceBundle bundle, BiFunction<ResourceBundle,String,Translation> extractor)
      Registers the entries of the given resource bundle.
      Parameters:
      bundle - the resource bundle
      extractor - the function to extract Translation
    • registerAll

      default void registerAll(Collection<ResourceBundle> bundles)
      Registers the entries of the given resource bundles as text translations.
      Parameters:
      bundles - the collection of resource bundles
    • registerAll

      default void registerAll(Collection<ResourceBundle> bundles, BiFunction<ResourceBundle,String,Translation> extractor)
      Registers the entries of the given resource bundles.
      Parameters:
      bundles - the collection of resource bundles
      extractor - the function to extract Translation
    • registerAll

      default void registerAll(Locale locale, Set<String> keys, Function<String,Translation> mapper)
      Registers a set of translations by using a mapper function to obtain each translation.
      Parameters:
      locale - the locale of the translations
      keys - the set of keys to register
      mapper - the mapper function to obtain the translation
      Throws:
      IllegalArgumentException - if the key is already registered
    • register

      void register(String key, Locale locale, Translation translation)
      Registers a translation.
      Parameters:
      key - the key of the translation
      locale - the locale of the translation
      translation - the translation
      Throws:
      IllegalArgumentException - if the key is already registered
    • registered

      boolean registered(String key)
      Checks if a key is registered for any locale.
      Parameters:
      key - the key of
      Returns:
      true if the key is registered, false otherwise
    • registered

      boolean registered(String key, Locale locale)
      Checks if a key is registered for a specific locale.
      Parameters:
      key - the key
      locale - the locale to check
      Returns:
      true if the key is registered for the specific locale, false otherwise
    • unregister

      void unregister(String key)
      Unregisters a key.
      Parameters:
      key - the key of the string
    • unregister

      void unregister(String key, Locale locale)
      Unregisters a key for a specific locale.
      Parameters:
      key - the key
      locale - the locale
    • clear

      void clear()
      Unregisters all translations.
    • getDefaultLocale

      Locale getDefaultLocale()
      Returns the default locale of this source.
    • getKeys

      Collection<String> getKeys()
      Returns the keys of all registered translations.
    • getKeys

      Collection<String> getKeys(Locale locale)
      Returns the keys of all registered translations for a specific locale.
      Parameters:
      locale - the locale