Class LocalizationService
java.lang.Object
com.zetaplugins.zetacore.services.LocalizationService
Service for handling localization and language files.
This service loads the language file based on the configuration and provides methods to retrieve localized strings.
-
Constructor Summary
ConstructorsConstructorDescriptionLocalizationService(JavaPlugin plugin, List<String> defaultLangs) LocalizationService(JavaPlugin plugin, List<String> defaultLangs, String fallbackLang, String langFolder, String langConfigOption) -
Method Summary
Modifier and TypeMethodDescriptionGet a string from the language fileGet a string from the language file with a fallbackgetStringList(String key) Get a list of strings from the language filevoidreload()Reload the language configuration from the language files
-
Constructor Details
-
LocalizationService
- Parameters:
plugin- The JavaPlugin instance to use for loading resourcesdefaultLangs- List of default language codes to load (The languages that are provided by the plugin)
-
LocalizationService
public LocalizationService(JavaPlugin plugin, List<String> defaultLangs, String fallbackLang, String langFolder, String langConfigOption) - Parameters:
plugin- The JavaPlugin instance to use for loading resourcesdefaultLangs- List of default language codes to load (The languages that are provided by the plugin)fallbackLang- The fallback language code to use if the selected language is not foundlangFolder- The folder where the language files are stored (e.g., "lang/")langConfigOption- The configuration option to use for selecting the language (e.g., "lang")
-
-
Method Details
-
reload
public void reload()Reload the language configuration from the language files -
getString
Get a string from the language file- Parameters:
key- The key to get the string for- Returns:
- The string from the language file
-
getString
Get a string from the language file with a fallback- Parameters:
key- The key to get the string forfallback- The fallback string- Returns:
- The string from the language file or the fallback
-
getStringList
Get a list of strings from the language file- Parameters:
key- The key to get the list of strings for- Returns:
- The list of strings from the language file
-