Package net.kyori.adventure.translation
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
-
Nested Class Summary
Nested classes/interfaces inherited from class net.kyori.adventure.translation.AbstractTranslationStore
AbstractTranslationStore.StringBased<T>
Nested classes/interfaces inherited from interface net.kyori.adventure.translation.TranslationStore
TranslationStore.StringBased<T>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
StringBased
(@NotNull Key name) Creates a new abstract, string-based translation store with a given name. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract T
Parses a string into the format required for this translation store.final void
registerAll
(@NotNull Locale locale, @NotNull Path path, boolean escapeSingleQuotes) Registers a resource bundle of translations.final void
registerAll
(@NotNull Locale locale, @NotNull ResourceBundle bundle, boolean escapeSingleQuotes) Registers a resource bundle of translations.Methods inherited from class net.kyori.adventure.translation.AbstractTranslationStore
canTranslate, contains, contains, defaultLocale, equals, examinableProperties, hasAnyTranslations, hashCode, name, register, registerAll, registerAll, toString, translationValue, unregister
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.kyori.examination.Examinable
examinableName, examine
Methods inherited from interface net.kyori.adventure.translation.TranslationStore
canTranslate, contains, contains, defaultLocale, register, registerAll, registerAll, unregister
Methods inherited from interface net.kyori.adventure.translation.Translator
hasAnyTranslations, name, translate, translate
-
Constructor Details
-
StringBased
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 stringlocale
- 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 interfaceTranslationStore.StringBased<T>
- Parameters:
locale
- a localepath
- a path to the resource bundleescapeSingleQuotes
- 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 interfaceTranslationStore.StringBased<T>
- Parameters:
locale
- a localebundle
- a resource bundleescapeSingleQuotes
- whether to escape single quotes- See Also:
-