Class LocalizationService

java.lang.Object
com.zetaplugins.zetacore.services.LocalizationService

public final class LocalizationService extends Object
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 Details

    • LocalizationService

      public LocalizationService(JavaPlugin plugin, List<String> defaultLangs)
      Parameters:
      plugin - The JavaPlugin instance to use for loading resources
      defaultLangs - 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 resources
      defaultLangs - 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 found
      langFolder - 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

      public String getString(String key)
      Get a string from the language file
      Parameters:
      key - The key to get the string for
      Returns:
      The string from the language file
    • getString

      public String getString(String key, String fallback)
      Get a string from the language file with a fallback
      Parameters:
      key - The key to get the string for
      fallback - The fallback string
      Returns:
      The string from the language file or the fallback
    • getStringList

      public List<String> getStringList(String key)
      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