Package one.tranic.t.i18n
Class KyoriLoader
java.lang.Object
one.tranic.t.i18n.BaseLoader
one.tranic.t.i18n.KyoriLoader
-
Nested Class Summary
Nested classes/interfaces inherited from class one.tranic.t.i18n.BaseLoader
BaseLoader.SimpleComponent -
Constructor Summary
ConstructorsConstructorDescriptionKyoriLoader(@NotNull File file, @NotNull I18n adaptar) KyoriLoader(@NotNull Class<?> clazz, @NotNull String namespace, @NotNull Locale locale, @NotNull I18n adaptar) KyoriLoader(@NotNull Class<?> clazz, @NotNull String namespace, @NotNull I18n adaptar) KyoriLoader(@NotNull String namespace, @NotNull I18n adaptar) KyoriLoader(@NotNull Path path, @NotNull I18n adaptar) KyoriLoader(@Nullable File file, @Nullable Path path, @Nullable Class<?> clazz, @Nullable String namespace, @Nullable Locale locale, @NotNull I18n adaptar) -
Method Summary
Modifier and TypeMethodDescriptionnet.kyori.adventure.text.ComponenttoComponent(@NotNull String key) Converts the provided translation key into an Adventure Component.net.kyori.adventure.text.ComponenttoComponent(@NotNull String key, @NotNull Object... args) Converts the translation key and its formatted arguments into an Adventure Component.net.kyori.adventure.text.ComponenttoComponent(@NotNull String key, @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... tagResolvers) Converts the translation key into aComponentusing MiniMessage format.net.kyori.adventure.text.ComponenttoComponentBrace(@NotNull String key, @NotNull Object... args) Converts the provided translation key and its formatted arguments into an Adventure Component.net.kyori.adventure.text.ComponenttoComponentBrace(@NotNull String key, @NotNull BaseLoader.SimpleComponent... args) Converts the given key and arguments into a formatted text component using braces for placeholders.toString()Methods inherited from class one.tranic.t.i18n.BaseLoader
createMap, getLanguage, getLanguageMap, hashCode, reset, reset, setLanguage, to, to, toBrace, toBrace, update, update, update
-
Constructor Details
-
KyoriLoader
-
KyoriLoader
public KyoriLoader(@NotNull @NotNull String namespace, @NotNull @NotNull I18n adaptar) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
KyoriLoader
public KyoriLoader(@NotNull @NotNull Path path, @NotNull @NotNull I18n adaptar) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
KyoriLoader
public KyoriLoader(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull String namespace, @NotNull @NotNull I18n adaptar) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
KyoriLoader
public KyoriLoader(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull String namespace, @NotNull @NotNull Locale locale, @NotNull @NotNull I18n adaptar) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
KyoriLoader
public KyoriLoader(@Nullable @Nullable File file, @Nullable @Nullable Path path, @Nullable @Nullable Class<?> clazz, @Nullable @Nullable String namespace, @Nullable @Nullable Locale locale, @NotNull @NotNull I18n adaptar) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
-
Method Details
-
toString
- Overrides:
toStringin classBaseLoader
-
toComponent
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 stringargs- 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 stringargs- 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 nullargs- 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 aComponentusing 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 stringtagResolvers- optional tag resolvers used to process placeholders or tags within the localized string- Returns:
- the
Componentrepresentation of the translated key, or a plain text component containing the key if no translation exists - See Also:
-