Interface ILocalizer

All Known Implementing Classes:
ILocalizer.DummyLocalizer, Localizer

public interface ILocalizer
Basic Interface for localizer implementations.

Also allows access to localizer instances per plugin.

Since:
1.0.0
  • Field Details

  • Method Details

    • getPluginLocalizer

      static ILocalizer getPluginLocalizer(Plugin plugin)
    • getPluginLocalizer

      static ILocalizer getPluginLocalizer(Class<? extends Plugin> plugin)
    • plugin

      Plugin plugin()
    • escape

      static String escape(String propertyKey)
    • isLocaleCode

      static boolean isLocaleCode(String message)
    • setLocale

      void setLocale(String language)
      Sets the locale of the localizer instance.
      Parameters:
      language - language to set.
    • getMessage

      String getMessage(String key)
      Get a message.
      Parameters:
      key - message key
      Returns:
      message with replaced replacements if present.
    • getIncludedLocales

      String[] getIncludedLocales()
      Returns all available locales.
      Returns:
      array of registered locales.
    • includedLocales

      Set<String> includedLocales()
      Returns all available locales.
      Returns:
      set of registered locales.
    • addLocaleCodes

      void addLocaleCodes(Map<String,String> runtimeLocaleCodes)
      Add requested locale codes in runtime.

      This has to be done before calling setLocale(String)

      Every key has one default value which will be added to the file if the key is not present.

      Parameters:
      runtimeLocaleCodes - map with locales codes to add.
    • getMessage

      String getMessage(String key, CommandSender sender)
    • getValue

    • getMessage

      String getMessage(String key, String language)
    • getValue

      @Nullable @Nullable String getValue(String key, CommandSender sender)
    • getValue

      @Nullable @Nullable String getValue(String key, String language)
    • localeBundle

      ResourceBundle localeBundle(String language)
    • defaultBundle

      ResourceBundle defaultBundle()
    • localize

      default String localize(String message)
      Translates a String with Placeholders. Can handle multiple messages with replacements. Add replacements in the right order.
      Parameters:
      message - Message to translate
      Returns:
      Replaced Messages
      Since:
      1.2.3
    • localize

      String localize(CommandSender sender, String message)
      Translates a String with Placeholders. Can handle multiple messages with replacements. Add replacements in the right order.
      Parameters:
      message - Message to translate
      Returns:
      Replaced Messages
      Since:
      1.2.3
    • registerChild

      void registerChild(ILocalizer localizer)