Class MessageFormatter
java.lang.Object
dev.vanengine.core.MessageFormatter
Simple {key} placeholder replacement for i18n messages,
with optional plural resolution and HTML-safe formatting.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringReplace {key} placeholders in the message with values from the params map.static StringformatSafe(String message, Map<String, ?> params) Same asformat(String, Map), but HTML-escapes parameter values before substitution.static StringresolvePlural(String message, int count) Resolve plural forms separated by|(pipe).
-
Method Details
-
format
Replace {key} placeholders in the message with values from the params map. If the message contains pipe-separated plural forms and params contains "count", the appropriate form is selected first. Unmatched placeholders are left as-is. -
formatSafe
Same asformat(String, Map), but HTML-escapes parameter values before substitution. Use this when the output will be embedded in HTML to prevent XSS. -
resolvePlural
Resolve plural forms separated by|(pipe).Rules (vue-i18n compatible):
- 2 forms:
"singular | plural"— 0,1 → first; 2+ → second - 3 forms:
"zero | singular | plural"— 0 → first; 1 → second; 2+ → third
- 2 forms:
-