Enum Class I18nUtil

java.lang.Object
java.lang.Enum<I18nUtil>
dk.lockfuglsang.minecraft.po.I18nUtil
All Implemented Interfaces:
Serializable, Comparable<I18nUtil>, Constable

public enum I18nUtil extends Enum<I18nUtil>
Convenience util for supporting static imports.
  • Method Details

    • values

      public static I18nUtil[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static I18nUtil valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • tr

      @NotNull public static @NotNull String tr(@Nullable @Nullable String s)
      Translates the given String to the configured language. Returns the given String if no translation is available. Returns an empty String if the given key is null or empty.
      Parameters:
      s - String to translate.
      Returns:
      Translated String.
    • tr

      @NotNull public static @NotNull String tr(@Nullable @Nullable String s, @Nullable @Nullable Object... args)
      Translates the given String to the configured language. Formats with the given Object. Returns the given String if no translation is available. Returns an empty String if the given key is null or empty.
      Parameters:
      s - String to translate.
      args - Arguments to format.
      Returns:
      Translated String.
    • marktr

      @Contract("null -> null") public static String marktr(@Nullable @Nullable String key)
      Marks the given String for translation for the .po files.
      Parameters:
      key - String to mark.
      Returns:
      Input String.
    • pre

      @NotNull public static @NotNull String pre(@Nullable @Nullable String s, @Nullable @Nullable Object... args)
      Formats the given String without translating. Returns an empty String if the given String is null or empty.
      Parameters:
      s - String to format.
      args - Arguments for formatting.
      Returns:
      Formatted String.
    • getI18n

      public static I18nUtil.I18n getI18n()
      Gets the I18nUtil.I18n instance representing the configured Locale. Lazy-loads if necessary.
      Returns:
      I18n instance for the configured locale.
    • getLocale

      @NotNull public static @NotNull Locale getLocale()
      Returns the configured Locale or the default if unset.
      Returns:
      Configured Locale.
    • setLocale

      public static void setLocale(@Nullable @Nullable Locale locale)
      Sets the Locale. Resets to the default locale if NULL is given.
      Parameters:
      locale - Locale to set.
    • setDataFolder

      public static void setDataFolder(@NotNull @NotNull File folder)
      Sets the datafolder that is used to look for .po files.
      Parameters:
      folder - Location of the datafolder.
    • clearCache

      public static void clearCache()
      Clears the I18n cache, forces a reload of the .po files the next time that getLocale() is accessed.
    • getLocale

      @Contract("null -> null") public static Locale getLocale(@Nullable @Nullable String lang)
      Converts the given String to a Locale.
      Parameters:
      lang - Language code..
      Returns:
      Locale based on the given string.