Class LanguageManager
java.lang.Object
dev.sefiraat.sefilib.localization.LanguageManager
This class can be used to provide different strings based on the server's chosen language.
-
Constructor Summary
ConstructorsConstructorDescriptionLanguageManager(JavaPlugin javaPlugin, String langDirectory, String chosenLang, String defaultLang) Creates a new instance of theLanguageManagerclass. -
Method Summary
Modifier and TypeMethodDescriptionGets the default language file.Gets the plugin instance.Gets the selected language file.Gets the string for the given path.Gets the string for the given path.String[]getStringArray(String path) Gets the string list for the given path.String[]getStringArray(String path, Object... replacements) Gets the string list for the given path.getStringList(String path) Gets the string list for the given path.getStringList(String path, Object... replacements) Gets the string list for the given path.
-
Constructor Details
-
LanguageManager
@ParametersAreNonnullByDefault public LanguageManager(JavaPlugin javaPlugin, String langDirectory, String chosenLang, String defaultLang) Creates a new instance of theLanguageManagerclass.- Parameters:
javaPlugin- TheJavaPlugininstance.langDirectory- The directory where the language files are located. This is relative to the plugin's data folder.chosenLang- The language that is currently selected by the server.defaultLang- The language that is used as a fallback if the selected language is not available or if the string is not available.
-
-
Method Details
-
getString
Gets the string for the given path. Will fallback to the default language if the string is not available.- Parameters:
path- The path to the string.- Returns:
- The string for the given path in the selected language or the default language if the string is not available.
-
getString
Gets the string for the given path. Will fallback to the default language if the string is not available.- Parameters:
path- The path to the string.replacements- The replacements to use for the strings.- Returns:
- The string for the given path in the selected language or the default language if the string is not available.
-
getStringList
Gets the string list for the given path. Will fallback to the default language if the string is not available.- Parameters:
path- The path to the string.- Returns:
- The string list for the given path in the selected language or the default language if the string is not available.
-
getStringList
Gets the string list for the given path. Will fallback to the default language if the string is not available.- Parameters:
path- The path to the string.replacements- The replacements to use for the strings.- Returns:
- The string list for the given path in the selected language or the default language if the string is not available.
-
getStringArray
Gets the string list for the given path. Will fallback to the default language if the string is not available.- Parameters:
path- The path to the string.- Returns:
- The string list for the given path in the selected language or the default language if the string is not available.
-
getStringArray
Gets the string list for the given path. Will fallback to the default language if the string is not available.- Parameters:
path- The path to the string.replacements- The replacements to use for the strings.- Returns:
- The string list for the given path in the selected language or the default language if the string is not available.
-
getJavaPlugin
Gets the plugin instance.- Returns:
- The plugin instance.
-
getDefaultLanguage
Gets the default language file.- Returns:
- The default language file.
-
getSelectedLanguage
Gets the selected language file.- Returns:
- The selected language file.
-