Class BukkitLocalizationService

java.lang.Object
com.zetaplugins.zetacore.services.localization.BukkitLocalizationService
All Implemented Interfaces:
LocalizationService

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

    • BukkitLocalizationService

      public BukkitLocalizationService(JavaPlugin plugin, List<String> possibleLangs)
      Parameters:
      plugin - The JavaPlugin instance to use for loading resources
      possibleLangs - List of language codes to load (The languages that are provided by the plugin)
    • BukkitLocalizationService

      public BukkitLocalizationService(JavaPlugin plugin, List<String> possibleLangs, String fallbackLang, String langFolder, String langConfigOption)
      Parameters:
      plugin - The JavaPlugin instance to use for loading resources
      possibleLangs - List of 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)
      Description copied from interface: LocalizationService
      Get a string from the language file
      Specified by:
      getString in interface LocalizationService
      Parameters:
      key - The key to get the string for
      Returns:
      The string from the language file
    • getString

      public String getString(String key, String fallback)
      Description copied from interface: LocalizationService
      Get a string from the language file with a fallback
      Specified by:
      getString in interface LocalizationService
      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)
      Description copied from interface: LocalizationService
      Get a list of strings from the language file
      Specified by:
      getStringList in interface LocalizationService
      Parameters:
      key - The key to get the list of strings for
      Returns:
      The list of strings from the language file