Class KyoriLoader

java.lang.Object
one.tranic.t.i18n.BaseLoader
one.tranic.t.i18n.KyoriLoader

public class KyoriLoader extends BaseLoader
  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class BaseLoader
    • toComponent

      @NotNull public net.kyori.adventure.text.Component toComponent(@NotNull @NotNull String key)
      Converts the provided translation key into an Adventure Component.
      Parameters:
      key - the translation key used to fetch the corresponding localized string
      Returns:
      an Adventure Component containing the localized string for the given translation key, or the key itself if no translation exists
    • toComponent

      @NotNull public net.kyori.adventure.text.Component toComponent(@NotNull @NotNull String key, @NotNull @NotNull Object... args)
      Converts the translation key and its formatted arguments into an Adventure Component.

      The format follows printf-style format strings, for example:

       "Hello %s" with arg "world" produces "Hello world"
       "%d items" with arg 5 produces "5 items"
       "Rate: %.2f" with arg 0.123 produces "Rate: 0.12"
       
      Parameters:
      key - the translation key used to fetch the corresponding localized string
      args - the arguments to format the localized string
      Returns:
      an Adventure Component containing the localized and formatted string for the given translation key, or a plain text Component containing the key if no translation exists
    • toComponentBrace

      @NotNull public net.kyori.adventure.text.Component toComponentBrace(@NotNull @NotNull String key, @NotNull @NotNull Object... args)
      Converts the provided translation key and its formatted arguments into an Adventure Component.

      For example:

       "{} items in {}" with args ["5", "cart"] produces "5 items in cart"
       "Hello {}" with arg "world" produces "Hello world"
       "Rate: {}" with arg "0.12" produces "Rate: 0.12"
       
      Parameters:
      key - the translation key used to fetch the corresponding localized string
      args - the arguments to replace the "{}" placeholders within the localized string
      Returns:
      an Adventure Component containing the localized and formatted string for the given key, or the key itself as a plain text Component if no translation exists
    • toComponentBrace

      @NotNull public net.kyori.adventure.text.Component toComponentBrace(@NotNull @NotNull String key, @NotNull @NotNull BaseLoader.SimpleComponent... args)
      Converts the given key and arguments into a formatted text component using braces for placeholders.

      For example:

       "{b1} items in {b2}" with args {"b1": "5", "b2", "cart"} produces "5 items in cart"
       "Hello {b1}" with arg {"b1", "world"} produces "Hello world"
       "Rate: {b1}" with arg {"b1", 0.12} produces "Rate: 0.12"
       
      Parameters:
      key - the key used as the base text for the component must not be null
      args - the arguments to be placed into the placeholders within the text must not be null
      Returns:
      a Component instance representing the formatted text
    • toComponent

      @NotNull public net.kyori.adventure.text.Component toComponent(@NotNull @NotNull String key, @NotNull @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... tagResolvers)
      Converts the translation key into a Component using MiniMessage format.

      For example:

      
       "Click <click:run_command:/help>here</click> for help" produces a clickable "here" text
       "This is <red>red text</red>" produces text with red color
       "Player: <player>" with player tag resolver shows player name
       
      Parameters:
      key - the translation key used to fetch the corresponding localized string
      tagResolvers - optional tag resolvers used to process placeholders or tags within the localized string
      Returns:
      the Component representation of the translated key, or a plain text component containing the key if no translation exists
      See Also: