MessageFormatter
- Namespace: Turian.Engine.Core
- Source File: MessageFormatter.cs
Formats the ICU MessageFormat subset a string table may use: plain {name} substitution, the # plural placeholder, and {name, plural, …} / {name, select, …} blocks.
Remarks
Deliberately small — enough for a game's strings without pulling in a full ICU engine. Nested blocks, =N exact matches and number/date skeletons are not supported; an unrecognised construct is passed through verbatim rather than dropped, so a malformed string is visible in the UI instead of silently losing text.
Public Methods
Format
public static string Format(string message, decimal? count = null, string locale = "en", IReadOnlyDictionary<string, object?>? values = null)
Formats a message with an optional plural count and named values.
Parameters:
message(string): The raw message, possibly containing{…}blocks.count(decimal?): The count selecting a plural variant, ornull. (Default:null)locale(string): The locale whose plural rules apply. (Default:"en")values(IReadOnlyDictionary<string, object?>?): Additional named substitutions, ornull. (Default:null)
Returns: string
- The formatted string.