Package dk.lockfuglsang.minecraft.po
Enum Class I18nUtil
- All Implemented Interfaces:
Serializable
,Comparable<I18nUtil>
,Constable
Convenience util for supporting static imports.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Proxy between uSkyBlock and org.xnap.commons.i18n.I18nNested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Clears the I18n cache, forces a reload of the .po files the next time thatgetLocale()
is accessed.static I18nUtil.I18n
getI18n()
Gets theI18nUtil.I18n
instance representing the configuredLocale
.static @NotNull Locale
Returns the configuredLocale
or the default if unset.static Locale
static String
Marks the givenString
for translation for the .po files.static @NotNull String
Formats the givenString
without translating.static void
setDataFolder
(@NotNull File folder) Sets the datafolder that is used to look for .po files.static void
Sets theLocale
.static @NotNull String
Translates the givenString
to the configured language.static @NotNull String
Translates the givenString
to the configured language.static I18nUtil
Returns the enum constant of this class with the specified name.static I18nUtil[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
tr
Translates the givenString
to the configured language. Returns the given String if no translation is available. Returns an empty String if the given key is null or empty.- Parameters:
s
- String to translate.- Returns:
- Translated String.
-
tr
@NotNull public static @NotNull String tr(@Nullable @Nullable String s, @Nullable @Nullable Object... args) Translates the givenString
to the configured language. Formats with the givenObject
. Returns the given String if no translation is available. Returns an empty String if the given key is null or empty.- Parameters:
s
- String to translate.args
- Arguments to format.- Returns:
- Translated String.
-
marktr
Marks the givenString
for translation for the .po files.- Parameters:
key
- String to mark.- Returns:
- Input String.
-
pre
@NotNull public static @NotNull String pre(@Nullable @Nullable String s, @Nullable @Nullable Object... args) Formats the givenString
without translating. Returns an empty String if the given String is null or empty.- Parameters:
s
- String to format.args
- Arguments for formatting.- Returns:
- Formatted String.
-
getI18n
Gets theI18nUtil.I18n
instance representing the configuredLocale
. Lazy-loads if necessary.- Returns:
- I18n instance for the configured locale.
-
getLocale
Returns the configuredLocale
or the default if unset.- Returns:
- Configured Locale.
-
setLocale
Sets theLocale
. Resets to the default locale if NULL is given.- Parameters:
locale
- Locale to set.
-
setDataFolder
Sets the datafolder that is used to look for .po files.- Parameters:
folder
- Location of the datafolder.
-
clearCache
public static void clearCache()Clears the I18n cache, forces a reload of the .po files the next time thatgetLocale()
is accessed. -
getLocale
- Parameters:
lang
- Language code..- Returns:
- Locale based on the given string.
-