Class BaseTranslator
java.lang.Object
com.guflimc.brick.i18n.api.translator.BaseTranslator
- Direct Known Subclasses:
ExtendedTranslator
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Locale
protected final String
protected final net.kyori.adventure.translation.TranslationRegistry
protected final StandardComponentRenderer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal net.kyori.adventure.text.Component
center
(int width, net.kyori.adventure.text.Component component) final net.kyori.adventure.text.Component
center
(net.kyori.adventure.text.Component component) final net.kyori.adventure.text.Component
final net.kyori.adventure.text.Component
hoverable
(net.kyori.adventure.audience.Audience audience, @NotNull String msgKey, @NotNull String hoverKey) final String
id()
final void
importTranslations
(URL resource) final void
importTranslations
(URL resource, Locale locale) final void
importTranslations
(Path path) final net.kyori.adventure.text.Component
maybeTranslate
(Locale locale, net.kyori.adventure.text.Component component) Translates the component if the given parameter is aTranslatableComponent
.final net.kyori.adventure.text.Component
maybeTranslate
(net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.Component component) final void
menu
(net.kyori.adventure.audience.Audience audience, char borderShape, net.kyori.adventure.text.format.TextColor borderColor, net.kyori.adventure.text.Component... components) final void
menu
(net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.Component... components) final net.kyori.adventure.text.Component
paddingAround
(int width, net.kyori.adventure.text.Component... components) final net.kyori.adventure.text.Component
paddingAround
(net.kyori.adventure.text.Component... components) final void
final void
final void
send
(net.kyori.adventure.audience.Audience audience, String key, net.kyori.adventure.text.Component... args) void
send
(net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.TranslatableComponent component) protected final net.kyori.adventure.text.TranslatableComponent
translatable
(String key, Object... args) protected final net.kyori.adventure.text.TranslatableComponent
translatable
(String key, net.kyori.adventure.text.Component... args) final net.kyori.adventure.text.Component
final net.kyori.adventure.text.Component
final net.kyori.adventure.text.Component
final net.kyori.adventure.text.Component
final net.kyori.adventure.text.Component
translate
(Locale locale, Duration duration, DurationFormatter formatter) This will replace the following time placeholders with their respective translation: Y - time.year M - time.month D - time.day h - time.hour m - time.minute s - time.secondfinal net.kyori.adventure.text.Component
final net.kyori.adventure.text.Component
final net.kyori.adventure.text.Component
final net.kyori.adventure.text.Component
translate
(net.kyori.adventure.audience.Audience audience, String key, net.kyori.adventure.text.Component... args) final net.kyori.adventure.text.Component
final net.kyori.adventure.text.Component
translate
(net.kyori.adventure.audience.Audience audience, Duration duration, DurationFormatter formatter) final net.kyori.adventure.text.Component
translate
(net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.TranslatableComponent component) final int
width
(net.kyori.adventure.text.Component component)
-
Field Details
-
registry
protected final net.kyori.adventure.translation.TranslationRegistry registry -
defaultLocale
-
id
-
renderer
-
-
Constructor Details
-
BaseTranslator
-
-
Method Details
-
id
-
translate
public final net.kyori.adventure.text.Component translate(Locale locale, net.kyori.adventure.text.TranslatableComponent component) -
translate
-
translate
-
translate
-
translate
public final net.kyori.adventure.text.Component translate(net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.TranslatableComponent component) -
translate
public final net.kyori.adventure.text.Component translate(net.kyori.adventure.audience.Audience audience, String key) -
translate
-
translate
public final net.kyori.adventure.text.Component translate(net.kyori.adventure.audience.Audience audience, String key, net.kyori.adventure.text.Component... args) -
send
public void send(net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.TranslatableComponent component) -
send
-
send
-
send
public final void send(net.kyori.adventure.audience.Audience audience, String key, net.kyori.adventure.text.Component... args) -
translatable
-
translatable
protected final net.kyori.adventure.text.TranslatableComponent translatable(String key, net.kyori.adventure.text.Component... args) -
hoverable
-
hoverable
-
paddingAround
public final net.kyori.adventure.text.Component paddingAround(net.kyori.adventure.text.Component... components) -
paddingAround
public final net.kyori.adventure.text.Component paddingAround(int width, net.kyori.adventure.text.Component... components) -
center
public final net.kyori.adventure.text.Component center(net.kyori.adventure.text.Component component) -
center
public final net.kyori.adventure.text.Component center(int width, net.kyori.adventure.text.Component component) -
width
public final int width(net.kyori.adventure.text.Component component) -
translate
public final net.kyori.adventure.text.Component translate(Locale locale, Duration duration, DurationFormatter formatter) This will replace the following time placeholders with their respective translation:- Y - time.year
- M - time.month
- D - time.day
- h - time.hour
- m - time.minute
- s - time.second
- Parameters:
locale
- the locale to useduration
- the duration to formatformatter
- the formatter to use- Returns:
- the translated and formatted duration
-
translate
-
translate
public final net.kyori.adventure.text.Component translate(net.kyori.adventure.audience.Audience audience, Duration duration, DurationFormatter formatter) -
translate
public final net.kyori.adventure.text.Component translate(net.kyori.adventure.audience.Audience audience, Duration duration) -
maybeTranslate
public final net.kyori.adventure.text.Component maybeTranslate(Locale locale, net.kyori.adventure.text.Component component) Translates the component if the given parameter is aTranslatableComponent
. Otherwise, this method will search the text of the given component and replace any keys that are found with its translation. It will then return the resulting component. If no keys are found, this will exactly return the given component.- Parameters:
locale
- the locale to use for translationcomponent
- the component to translate- Returns:
- the translated component
-
maybeTranslate
public final net.kyori.adventure.text.Component maybeTranslate(net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.Component component) -
importTranslations
- Throws:
MalformedURLException
-
importTranslations
-
importTranslations
-