Class BaseTranslator

java.lang.Object
com.guflimc.brick.i18n.api.translator.BaseTranslator
Direct Known Subclasses:
ExtendedTranslator

public class BaseTranslator extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Locale
     
    protected final String
     
    protected final net.kyori.adventure.translation.TranslationRegistry
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseTranslator(String id, Locale defaultLocale)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final 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
    hoverable(Locale locale, @NotNull String msgKey, @NotNull String hoverKey)
     
    final net.kyori.adventure.text.Component
    hoverable(net.kyori.adventure.audience.Audience audience, @NotNull String msgKey, @NotNull String hoverKey)
     
    final String
    id()
     
    final void
     
    final void
    importTranslations(URL resource, Locale locale)
     
    final void
     
    final net.kyori.adventure.text.Component
    maybeTranslate(Locale locale, net.kyori.adventure.text.Component component)
    Translates the component if the given parameter is a TranslatableComponent.
    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
    send(net.kyori.adventure.audience.Audience audience, String key)
     
    final void
    send(net.kyori.adventure.audience.Audience audience, String key, Object... args)
     
    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
    translate(Locale locale, String key)
     
    final net.kyori.adventure.text.Component
    translate(Locale locale, String key, Object... args)
     
    final net.kyori.adventure.text.Component
    translate(Locale locale, String key, net.kyori.adventure.text.Component... args)
     
    final net.kyori.adventure.text.Component
    translate(Locale locale, Duration duration)
     
    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
    final net.kyori.adventure.text.Component
    translate(Locale locale, net.kyori.adventure.text.TranslatableComponent component)
     
    final net.kyori.adventure.text.Component
    translate(net.kyori.adventure.audience.Audience audience, String key)
     
    final net.kyori.adventure.text.Component
    translate(net.kyori.adventure.audience.Audience audience, String key, Object... args)
     
    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
    translate(net.kyori.adventure.audience.Audience audience, Duration duration)
     
    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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • registry

      protected final net.kyori.adventure.translation.TranslationRegistry registry
    • defaultLocale

      protected final Locale defaultLocale
    • id

      protected final String id
    • renderer

      protected final StandardComponentRenderer renderer
  • Constructor Details

    • BaseTranslator

      public BaseTranslator(String id, Locale defaultLocale)
  • Method Details

    • id

      public final String id()
    • translate

      public final net.kyori.adventure.text.Component translate(Locale locale, net.kyori.adventure.text.TranslatableComponent component)
    • translate

      public final net.kyori.adventure.text.Component translate(Locale locale, String key)
    • translate

      public final net.kyori.adventure.text.Component translate(Locale locale, String key, Object... args)
    • translate

      public final net.kyori.adventure.text.Component translate(Locale locale, String key, net.kyori.adventure.text.Component... args)
    • 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

      public final net.kyori.adventure.text.Component translate(net.kyori.adventure.audience.Audience audience, String key, Object... args)
    • 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

      public final void send(net.kyori.adventure.audience.Audience audience, String key)
    • send

      public final void send(net.kyori.adventure.audience.Audience audience, String key, Object... args)
    • send

      public final void send(net.kyori.adventure.audience.Audience audience, String key, net.kyori.adventure.text.Component... args)
    • translatable

      protected final net.kyori.adventure.text.TranslatableComponent translatable(String key, Object... args)
    • translatable

      protected final net.kyori.adventure.text.TranslatableComponent translatable(String key, net.kyori.adventure.text.Component... args)
    • hoverable

      public final net.kyori.adventure.text.Component hoverable(Locale locale, @NotNull @NotNull String msgKey, @NotNull @NotNull String hoverKey)
    • hoverable

      public final net.kyori.adventure.text.Component hoverable(net.kyori.adventure.audience.Audience audience, @NotNull @NotNull String msgKey, @NotNull @NotNull String hoverKey)
    • 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 use
      duration - the duration to format
      formatter - the formatter to use
      Returns:
      the translated and formatted duration
    • translate

      public final net.kyori.adventure.text.Component translate(Locale locale, Duration duration)
    • 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 a TranslatableComponent. 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 translation
      component - 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

      public final void importTranslations(Path path) throws MalformedURLException
      Throws:
      MalformedURLException
    • importTranslations

      public final void importTranslations(URL resource)
    • importTranslations

      public final void importTranslations(URL resource, Locale locale)