Interface Localizer

All Superinterfaces:
ViewProvider<Localizer>

@Experimental public interface Localizer extends ViewProvider<Localizer>
A Localizer is used for the localization of translatable strings. This API is highly experimental and will be subject to change due to pending localization reworks. In its current state, it acts as a bridge between old and new API.
See Also:
  • Method Details

    • of

      @Contract("_ -> new") static Localizer of(SkriptAddon addon)
      Parameters:
      addon - The addon this localizer is localizing for.
      Returns:
      A localizer with no default translations.
    • setSourceDirectories

      void setSourceDirectories(String languageFileDirectory, @Nullable @Nullable String dataFileDirectory)
      Sets the language file directories for this localizer. This method will initiate a loading of any language files in the provided directories.
      Parameters:
      languageFileDirectory - The path to the directory on the jar containing language files.
      dataFileDirectory - The path to the directory on the disk containing language files. For example, this may include language files that have been saved to enable user customization.
    • languageFileDirectory

      @Nullable @Nullable String languageFileDirectory()
      Returns:
      The path to the directory on the jar containing language files.
    • dataFileDirectory

      @Nullable @Nullable String dataFileDirectory()
      Returns:
      The path to the directory on the disk containing language files.
    • translate

      @Nullable @Nullable String translate(String key)
      Used for obtaining the translation of a language key.
      Parameters:
      key - The key of the translation to obtain.
      Returns:
      The translation represented by the provided key, or null if no translation exists.
    • unmodifiableView

      @Contract("-> new") default Localizer unmodifiableView()
      Constructs an unmodifiable view of this localizer. That is, no new translations may be added.
      Specified by:
      unmodifiableView in interface ViewProvider<Localizer>
      Returns:
      An unmodifiable view of this localizer.