Package one.tranic.t.i18n
Class BungeeLoader
java.lang.Object
one.tranic.t.i18n.BaseLoader
one.tranic.t.i18n.BungeeLoader
-
Nested Class Summary
Nested classes/interfaces inherited from class one.tranic.t.i18n.BaseLoader
BaseLoader.SimpleComponent -
Constructor Summary
ConstructorsConstructorDescriptionBungeeLoader(@NotNull File file, @NotNull I18n adaptar) BungeeLoader(@NotNull Class<?> clazz, @NotNull String namespace, @NotNull Locale locale, @NotNull I18n adaptar) BungeeLoader(@NotNull Class<?> clazz, @NotNull String namespace, @NotNull I18n adaptar) BungeeLoader(@NotNull String namespace, @NotNull I18n adaptar) BungeeLoader(@NotNull Path path, @NotNull I18n adaptar) BungeeLoader(@Nullable File file, @Nullable Path path, @Nullable Class<?> clazz, @Nullable String namespace, @Nullable Locale locale, @NotNull I18n adaptar) -
Method Summary
Modifier and TypeMethodDescription@NotNull net.md_5.bungee.api.chat.BaseComponent[]toBaseComponent(@NotNull String key) Converts a localized string corresponding to the given key into an array of BaseComponent objects.@NotNull net.md_5.bungee.api.chat.BaseComponent[]toBaseComponent(@NotNull String key, @NotNull Object... args) Converts a translation key and its formatted arguments into an array ofBaseComponent.@NotNull net.md_5.bungee.api.chat.BaseComponent[]toBaseComponentBrace(@NotNull String key, @NotNull Object... args) Converts a localized and formatted string with placeholders replaced by the provided arguments into an array ofBaseComponent.@NotNull net.md_5.bungee.api.chat.BaseComponent[]toBaseComponentBrace(@NotNull String key, @NotNull BaseLoader.SimpleComponent... args) Converts the provided key and arguments into an array of BaseComponent objects using a legacy text format with braces.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
-
BungeeLoader
-
BungeeLoader
public BungeeLoader(@NotNull @NotNull String namespace, @NotNull @NotNull I18n adaptar) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
BungeeLoader
public BungeeLoader(@NotNull @NotNull Path path, @NotNull @NotNull I18n adaptar) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
BungeeLoader
public BungeeLoader(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull String namespace, @NotNull @NotNull I18n adaptar) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
BungeeLoader
public BungeeLoader(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull String namespace, @NotNull @NotNull Locale locale, @NotNull @NotNull I18n adaptar) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
BungeeLoader
public BungeeLoader(@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
-
toBaseComponent
@NotNull public @NotNull net.md_5.bungee.api.chat.BaseComponent[] toBaseComponent(@NotNull @NotNull String key) Converts a localized string corresponding to the given key into an array of BaseComponent objects.- Parameters:
key- the translation key used to fetch the corresponding localized string- Returns:
- an array of BaseComponent objects representing the localized string, or the key itself as BaseComponents if no translation exists
-
toBaseComponent
@NotNull public @NotNull net.md_5.bungee.api.chat.BaseComponent[] toBaseComponent(@NotNull @NotNull String key, @NotNull @NotNull Object... args) Converts a translation key and its formatted arguments into an array ofBaseComponent.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 array of
BaseComponentrepresenting the localized and formatted text
-
toBaseComponentBrace
@NotNull public @NotNull net.md_5.bungee.api.chat.BaseComponent[] toBaseComponentBrace(@NotNull @NotNull String key, @NotNull @NotNull Object... args) Converts a localized and formatted string with placeholders replaced by the provided arguments into an array ofBaseComponent.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 array of
BaseComponentrepresenting the processed localized string
-
toBaseComponentBrace
@NotNull public @NotNull net.md_5.bungee.api.chat.BaseComponent[] toBaseComponentBrace(@NotNull @NotNull String key, @NotNull @NotNull BaseLoader.SimpleComponent... args) Converts the provided key and arguments into an array of BaseComponent objects using a legacy text format with braces.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 to be formatted, must not be nullargs- the array of SimpleComponent arguments to format, must not be null- Returns:
- an array of BaseComponent objects representing the formatted text
-