Class FrameworkText
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 Summary
Constructors -
Method Summary
-
Constructor Details
-
FrameworkText
private FrameworkText()
-
-
Method Details
-
text
Returns the text forkeyin the server's language.- Parameters:
key- the catalogue key (the Chinese source text)- Returns:
- the translation, or
keyitself when there is none or the catalogue is unavailable
-
format
Returnskeyin the server's language withargsapplied asString.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 specifiersargs- the format arguments- Returns:
- the formatted text
-