Package net.kyori.adventure.translation
Interface TranslationRegistry
- All Superinterfaces:
TranslationStore<MessageFormat>,TranslationStore.StringBased<MessageFormat>,Translator
@Deprecated
public interface TranslationRegistry
extends Translator, TranslationStore.StringBased<MessageFormat>
Deprecated.
A registry of translations. Used to register localized strings for translation keys. The registry can be submitted
to the
GlobalTranslator or can translate manually through translate(String, Locale).
The recommended way to register translations is through registerAll(Locale, ResourceBundle, boolean)
- Since:
- 4.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.kyori.adventure.translation.TranslationStore
TranslationStore.StringBased<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternDeprecated.For removal, since 4.20.0, with no replacement. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.For removal since 4.20.0.static @NotNull TranslationRegistryDeprecated.For removal since 4.20.0.voiddefaultLocale(@NotNull Locale locale) Deprecated.For removal since 4.20.0.voidregister(@NotNull String key, @NotNull Locale locale, @NotNull MessageFormat format) Deprecated.For removal since 4.20.0.default voidregisterAll(@NotNull Locale locale, @NotNull Path path, boolean escapeSingleQuotes) Deprecated.For removal since 4.20.0.default voidregisterAll(@NotNull Locale locale, @NotNull Map<String, MessageFormat> formats) Deprecated.For removal since 4.20.0.default voidregisterAll(@NotNull Locale locale, @NotNull ResourceBundle bundle, boolean escapeSingleQuotes) Deprecated.For removal since 4.20.0.default voidregisterAll(@NotNull Locale locale, @NotNull Set<String> keys, Function<String, MessageFormat> function) Deprecated.For removal since 4.20.0.@Nullable MessageFormatDeprecated.For removal since 4.20.0.voidunregister(@NotNull String key) Deprecated.For removal since 4.20.0.Methods inherited from interface net.kyori.adventure.translation.TranslationStore
canTranslate, containsMethods inherited from interface net.kyori.adventure.translation.Translator
hasAnyTranslations, name, translate
-
Field Details
-
SINGLE_QUOTE_PATTERN
Deprecated.For removal, since 4.20.0, with no replacement.A pattern which matches a single quote.- Since:
- 4.0.0
-
-
Method Details
-
create
Deprecated.For removal since 4.20.0. UseTranslationStore.messageFormat(Key)instead.Creates a new standalone translation registry.- Parameters:
name- the registry id- Returns:
- a translation registry
- Since:
- 4.0.0
-
contains
Deprecated.For removal since 4.20.0. UseTranslationStore.messageFormat(Key)instead.Checks if any translations are explicitly registered for the specified key.- Specified by:
containsin interfaceTranslationStore<MessageFormat>- Parameters:
key- a translation key- Returns:
- whether the registry contains a value for the translation key
- Since:
- 4.7.0
-
translate
@Deprecated @Nullable @Nullable MessageFormat translate(@NotNull @NotNull String key, @NotNull @NotNull Locale locale) Deprecated.For removal since 4.20.0. UseTranslationStore.messageFormat(Key)instead.Gets a message format from a key and locale.If a translation for
localeis not found, we will then trylocalewithout a country code, and then finally fallback to a default locale.- Specified by:
translatein interfaceTranslator- Parameters:
locale- a localekey- a translation key- Returns:
- a message format or
nullto skip translation - Since:
- 4.0.0
-
defaultLocale
Deprecated.For removal since 4.20.0. UseTranslationStore.messageFormat(Key)instead.Sets the default locale used by this registry.- Specified by:
defaultLocalein interfaceTranslationStore<MessageFormat>- Parameters:
locale- the locale to use a default- Since:
- 4.0.0
-
register
@Deprecated void register(@NotNull @NotNull String key, @NotNull @NotNull Locale locale, @NotNull @NotNull MessageFormat format) Deprecated.For removal since 4.20.0. UseTranslationStore.messageFormat(Key)instead.Registers a translation.final TranslationRegistry registry; registry.register("example.hello", Locale.US, new MessageFormat("Hi, {0}. How are you?"));- Specified by:
registerin interfaceTranslationStore<MessageFormat>- Parameters:
key- a translation keylocale- a localeformat- a translation format- Throws:
IllegalArgumentException- if the translation key is already exists- Since:
- 4.0.0
-
registerAll
@Deprecated default void registerAll(@NotNull @NotNull Locale locale, @NotNull @NotNull Map<String, MessageFormat> formats) Deprecated.For removal since 4.20.0. UseTranslationStore.messageFormat(Key)instead.Registers a map of translations.final TranslationRegistry registry; final Map<String, MessageFormat> translations; translations.put("example.greeting", new MessageFormat("Greetings {0}. Doing ok?)); translations.put("example.goodbye", new MessageFormat("Goodbye {0}. Have a nice day!)); registry.registerAll(Locale.US, translations);- Specified by:
registerAllin interfaceTranslationStore<MessageFormat>- Parameters:
locale- a localeformats- a map of translation keys to formats- Throws:
IllegalArgumentException- if a translation key already exists- Since:
- 4.0.0
- See Also:
-
registerAll
@Deprecated default void registerAll(@NotNull @NotNull Locale locale, @NotNull @NotNull Path path, boolean escapeSingleQuotes) Deprecated.For removal since 4.20.0. UseTranslationStore.messageFormat(Key)instead.Registers a resource bundle of translations.- Specified by:
registerAllin interfaceTranslationStore.StringBased<MessageFormat>- Parameters:
locale- a localepath- a path to the resource bundleescapeSingleQuotes- whether to escape single quotes- Throws:
IllegalArgumentException- if a translation key already exists- Since:
- 4.0.0
- See Also:
-
registerAll
@Deprecated default void registerAll(@NotNull @NotNull Locale locale, @NotNull @NotNull ResourceBundle bundle, boolean escapeSingleQuotes) Deprecated.For removal since 4.20.0. UseTranslationStore.messageFormat(Key)instead.Registers a resource bundle of translations.It is highly recommended to create your bundle using
UTF8ResourceBundleControlas your bundle control for UTF-8 support - for example:final ResourceBundle bundle = ResourceBundle.getBundle("my_bundle", Locale.GERMANY, UTF8ResourceBundleControl.get()); registry.registerAll(Locale.GERMANY, bundle, false);- Specified by:
registerAllin interfaceTranslationStore.StringBased<MessageFormat>- Parameters:
locale- a localebundle- a resource bundleescapeSingleQuotes- whether to escape single quotes- Throws:
IllegalArgumentException- if a translation key already exists- Since:
- 4.0.0
- See Also:
-
registerAll
@Deprecated default void registerAll(@NotNull @NotNull Locale locale, @NotNull @NotNull Set<String> keys, Function<String, MessageFormat> function) Deprecated.For removal since 4.20.0. UseTranslationStore.messageFormat(Key)instead.Registers a resource bundle of translations.- Specified by:
registerAllin interfaceTranslationStore<MessageFormat>- Parameters:
locale- a localekeys- the translation keys to registerfunction- a function to transform a key into a message format- Throws:
IllegalArgumentException- if a translation key already exists- Since:
- 4.0.0
-
unregister
Deprecated.For removal since 4.20.0. UseTranslationStore.messageFormat(Key)instead.Unregisters a translation key.- Specified by:
unregisterin interfaceTranslationStore<MessageFormat>- Parameters:
key- a translation key- Since:
- 4.0.0
-
TranslationStore.messageFormat(Key)instead.