Package ch.njol.skript.localization
Class Language
java.lang.Object
ch.njol.skript.localization.Language
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Some flagsstatic final int
Some flagsstatic final int
Some flagsstatic final int
masks out article flags - useful if the article has been added already (e.g. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addListener
(LanguageChangeListener listener) Registers a listener.static void
addListener
(LanguageChangeListener listener, Language.LanguageListenerPriority priority) static String
Gets a string and uses it as format inString.format(String, Object...)
.static String
Gets a string from the language file with the given key, or the key itself if the key does not exist.static @Nullable String
Equal toget(String)
, but returns null instead of the key if the key cannot be found.static String[]
Gets a list of strings.static String
getName()
static String
Gets a localized string surrounded by spaces, or a space if the string is emptystatic boolean
static boolean
static boolean
keyExistsDefault
(String key) static boolean
static void
loadDefault
(SkriptAddon addon) static void
missingEntryError
(String key)
-
Field Details
-
F_PLURAL
public static final int F_PLURALSome flags- See Also:
-
F_DEFINITE_ARTICLE
public static final int F_DEFINITE_ARTICLESome flags- See Also:
-
F_INDEFINITE_ARTICLE
public static final int F_INDEFINITE_ARTICLESome flags- See Also:
-
NO_ARTICLE_MASK
public static final int NO_ARTICLE_MASKmasks out article flags - useful if the article has been added already (e.g. by an adjective)- See Also:
-
-
Constructor Details
-
Language
public Language()
-
-
Method Details
-
getName
-
get
Gets a string from the language file with the given key, or the key itself if the key does not exist.- Parameters:
key
- The message's key (case-insensitive)- Returns:
- The requested message if it exists or the key otherwise
-
get_
Equal toget(String)
, but returns null instead of the key if the key cannot be found.- Parameters:
key
- The message's key (case-insensitive)- Returns:
- The requested message or null if it doesn't exist
-
missingEntryError
-
format
Gets a string and uses it as format inString.format(String, Object...)
.- Parameters:
args
- The arguments to pass toString.format(String, Object...)
- Returns:
- The formatted string
-
getSpaced
Gets a localized string surrounded by spaces, or a space if the string is empty- Returns:
- The message surrounded by spaces, a space if the entry is empty, or " "+key+" " if the entry is missing.
-
getList
Gets a list of strings.- Returns:
- a non-null String array with at least one element
-
keyExists
- Returns:
- Whether the given key exists in any loaded language file.
-
keyExistsDefault
- Returns:
- Whether the given key exists in the default language file.
-
isInitialized
public static boolean isInitialized()- Returns:
- whether the default language file is loaded.
-
loadDefault
-
load
-
addListener
Registers a listener. The listener will immediately be called if a language has already been loaded.- Parameters:
listener
- the listener to register
-
addListener
public static void addListener(LanguageChangeListener listener, Language.LanguageListenerPriority priority)
-