Package net.kyori.adventure.translation
Interface GlobalTranslator
-
- All Superinterfaces:
net.kyori.examination.Examinable
,Translator
public interface GlobalTranslator extends Translator, net.kyori.examination.Examinable
A global source of translations. The global source is the default source used by adventure platforms when rendering aTranslatableComponent
to anAudience
.To add your translations to this source, use
GlobalTranslator#get()#addSource(Translator)
with aTranslationRegistry
or your own implementation of aTranslator
.- Since:
- 4.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
addSource(@NotNull Translator source)
Adds a translation source.static @NotNull GlobalTranslator
get()
Gets the global translation source.boolean
removeSource(@NotNull Translator source)
Removes a translation source.static @NotNull Component
render(@NotNull Component component, @NotNull Locale locale)
Renders 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.-
Methods inherited from interface net.kyori.examination.Examinable
examinableName, examinableProperties, examine
-
Methods inherited from interface net.kyori.adventure.translation.Translator
name, translate
-
-
-
-
Method Detail
-
get
@NotNull static @NotNull GlobalTranslator get()
Gets the global translation source.- Returns:
- the source
- Since:
- 4.0.0
-
renderer
@NotNull static @NotNull TranslatableComponentRenderer<Locale> 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
@NotNull @NotNull Iterable<? extends Translator> sources()
Gets the sources.- Returns:
- the sources
- Since:
- 4.0.0
-
addSource
boolean addSource(@NotNull @NotNull Translator source)
Adds a translation source.Duplicate sources will be ignored.
- Parameters:
source
- the source- Returns:
true
if registered,false
otherwise- Throws:
IllegalArgumentException
- if source isGlobalTranslator
- Since:
- 4.0.0
-
removeSource
boolean removeSource(@NotNull @NotNull Translator source)
Removes a translation source.- Parameters:
source
- the source to unregister- Returns:
true
if unregistered,false
otherwise- Since:
- 4.0.0
-
-