Class FrameworkText

java.lang.Object
com.ultikits.ultitools.utils.FrameworkText

@Internal public final class FrameworkText extends Object
Resolves the framework's own operator-, player-, panel- and e-mail-facing text through the language catalogue (lang/en.json, lang/zh.json), so it follows the server's language setting.

By the catalogue's convention the key is the Chinese source text, zh.json maps it to itself and en.json gives the English. A text that has no entry in the active catalogue is returned unchanged, which is why a key is never a placeholder that could leak: it is always a readable sentence.

Never fails the caller. These calls sit in diagnostic and failure paths (a log line, an error reply), so a missing plugin instance (a unit test, or a call before the language is loaded) or a malformed translation must not turn the original problem into a second one. In both cases the key itself is used.

Since:
6.3.0
  • Constructor Details

    • FrameworkText

      private FrameworkText()
  • Method Details

    • text

      public static String text(String key)
      Returns the text for key in the server's language.
      Parameters:
      key - the catalogue key (the Chinese source text)
      Returns:
      the translation, or key itself when there is none or the catalogue is unavailable
    • format

      public static String format(String key, Object... args)
      Returns key in the server's language with args applied as String.format(String, Object...) would.

      The translation must carry the same placeholders, in the same order, as the key; the catalogue invariant test enforces that. If a translation nevertheless fails to format (an operator's edited language file, say), the key is formatted instead, so the line is still written.

      Parameters:
      key - the catalogue key (the Chinese source text), holding the format specifiers
      args - the format arguments
      Returns:
      the formatted text