Package net.kyori.adventure.translation
Interface GlobalTranslator
- All Superinterfaces:
net.kyori.examination.Examinable,Translator
A global source of translations. The global source is the default source used by adventure platforms
when rendering a
TranslatableComponent to an Audience.
To add your translations to this source, use GlobalTranslator#get()#addSource(Translator)
with a TranslationStore or your own implementation of a Translator.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddSource(@NotNull Translator source) Adds a translation source.static @NotNull GlobalTranslatorget()Deprecated.booleanremoveSource(@NotNull Translator source) Removes a translation source.static @NotNull ComponentRenders a component using theglobal renderer.static @NotNull TranslatableComponentRenderer<Locale>renderer()Gets a renderer which uses the global source for translating.@NotNull Iterable<? extends Translator>sources()Gets the sources.static @NotNull GlobalTranslatorGets the global translation source.Methods inherited from interface net.kyori.examination.Examinable
examinableName, examinableProperties, examineMethods inherited from interface net.kyori.adventure.translation.Translator
canTranslate, hasAnyTranslations, name, translate, translate
-
Method Details
-
translator
Gets the global translation source.- Returns:
- the source
- Since:
- 4.10.0
-
get
Deprecated.for removal since 4.10.0, usetranslator()instead.Gets the global translation source.- Returns:
- the source
- Since:
- 4.0.0
-
renderer
Gets a renderer which uses the global source for translating.- Returns:
- a renderer
- Since:
- 4.0.0
-
render
@NotNull static @NotNull Component render(@NotNull @NotNull Component component, @NotNull @NotNull Locale locale) Renders a component using theglobal renderer.- Parameters:
component- the component to renderlocale- the locale to use when rendering- Returns:
- the rendered component
- Since:
- 4.0.0
-
sources
Gets the sources.- Returns:
- the sources
- Since:
- 4.0.0
-
addSource
Adds a translation source.Duplicate sources will be ignored.
- Parameters:
source- the source- Returns:
trueif registered,falseotherwise- Throws:
IllegalArgumentException- if source isGlobalTranslator- Since:
- 4.0.0
-
removeSource
Removes a translation source.- Parameters:
source- the source to unregister- Returns:
trueif unregistered,falseotherwise- Since:
- 4.0.0
-
translator()instead.