Class AbstractTranslationStore.StringBased<T>

java.lang.Object
net.kyori.adventure.translation.AbstractTranslationStore<T>
net.kyori.adventure.translation.AbstractTranslationStore.StringBased<T>
Type Parameters:
T - the type of the translation
All Implemented Interfaces:
TranslationStore<T>, TranslationStore.StringBased<T>, Translator, net.kyori.examination.Examinable
Enclosing class:
AbstractTranslationStore<T>

public abstract static class AbstractTranslationStore.StringBased<T> extends AbstractTranslationStore<T> implements TranslationStore.StringBased<T>
An abstract, string-based translation store.

This class extends upon the standard abstract translation store by adding support for reading from resource bundles.

Since:
4.20.0
  • Constructor Details

    • StringBased

      protected StringBased(@NotNull @NotNull Key name)
      Creates a new abstract, string-based translation store with a given name.
      Parameters:
      name - the name
      Since:
      4.20.0
  • Method Details

    • parse

      @NotNull protected abstract T parse(@NotNull @NotNull String string, @NotNull @NotNull Locale locale)
      Parses a string into the format required for this translation store.
      Parameters:
      string - the string
      locale - the locale for the string, if needed
      Returns:
      the parsed type
      Since:
      4.20.0
    • registerAll

      public final void registerAll(@NotNull @NotNull Locale locale, @NotNull @NotNull Path path, boolean escapeSingleQuotes)
      Description copied from interface: TranslationStore.StringBased
      Registers a resource bundle of translations.
      Specified by:
      registerAll in interface TranslationStore.StringBased<T>
      Parameters:
      locale - a locale
      path - a path to the resource bundle
      escapeSingleQuotes - whether to escape single quotes
      See Also:
    • registerAll

      public final void registerAll(@NotNull @NotNull Locale locale, @NotNull @NotNull ResourceBundle bundle, boolean escapeSingleQuotes)
      Description copied from interface: TranslationStore.StringBased
      Registers a resource bundle of translations.

      It is highly recommended to create your bundle using UTF8ResourceBundleControl as your bundle control for UTF-8 support - for example:

      
         final TranslationStore store = ...;
         final ResourceBundle bundle = ResourceBundle.getBundle("my_bundle", Locale.GERMANY, UTF8ResourceBundleControl.get());
         store.registerAll(Locale.GERMANY, bundle, false);
       
      Specified by:
      registerAll in interface TranslationStore.StringBased<T>
      Parameters:
      locale - a locale
      bundle - a resource bundle
      escapeSingleQuotes - whether to escape single quotes
      See Also: