Class LanguageManager

java.lang.Object
dev.sefiraat.sefilib.localization.LanguageManager

public class LanguageManager extends Object
This class can be used to provide different strings based on the server's chosen language.
  • Constructor Details

    • LanguageManager

      @ParametersAreNonnullByDefault public LanguageManager(JavaPlugin javaPlugin, String langDirectory, String chosenLang, String defaultLang)
      Creates a new instance of the LanguageManager class.
      Parameters:
      javaPlugin - The JavaPlugin instance.
      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

      @Nonnull public String getString(@Nonnull String path)
      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

      @Nonnull public String getString(@Nonnull String path, Object... replacements)
      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

      @Nonnull public List<String> getStringList(@Nonnull String path)
      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

      @Nonnull public List<String> getStringList(@Nonnull String path, Object... replacements)
      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

      @Nonnull public String[] getStringArray(@Nonnull String path)
      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

      @Nonnull public String[] getStringArray(@Nonnull String path, Object... replacements)
      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

      public JavaPlugin getJavaPlugin()
      Gets the plugin instance.
      Returns:
      The plugin instance.
    • getDefaultLanguage

      public FileConfiguration getDefaultLanguage()
      Gets the default language file.
      Returns:
      The default language file.
    • getSelectedLanguage

      public FileConfiguration getSelectedLanguage()
      Gets the selected language file.
      Returns:
      The selected language file.