Message formats are used to put together sequences of strings, numbers, dates, and other formats to create messages. The message formatters facilitate localization because they prevent both hard-coding of message strings, and hard-coding of the concatenation sequence for portions of message strings. This means localizers can change the content, format, and order of any text as appropriate for any language.
The pattern is a sequence of text and arguments, all of which can be edited. The positions of the arguments within the sequence are indicated by a pair of braces "{...}" containing a digit n identifying the argument. The pattern in the demo applet has three arguments, numbered 0, 1, and 2. The arguments can appear in any order within the sequence, which can be edited and modified.
To See This... |
Do This... |
---|---|
You can move arguments freely within the sequence or delete arguments. You can also edit or translate any of the unformatted text. |
|
Translations are provided in the demo applet for several countries. |
|
Note: To add a real '{' character to the pattern, use single quotation marks.
The arguments can be either simple text strings or formattable, localizable objects. The pattern in the demo applet, for example, includes a date, an unformatted string, and a more complex format called a choice format (described below). You can edit these arguments at will. When localizing, you can also select any format to be associated with an argument.
To See This... |
Do This... |
---|---|
You can modify the value of any argument. |
|
You can change the format of any argument. |
|
Choice formats, like that used for argument 0, let localizers create more natural messages, avoiding phrases like "3 file(s)". As shown here, the correct text can be chosen for different numbers. This works even in more complicated contexts, such as Slavic languages which have more than one plural format based on the number involved. A particular choice is chosen based on the value of the argument, and each choice can be edited individually.
Look also at the format for the choice associated with values of 2 and higher. Such choices allow for a degree of flexibility in using different formats.
To See This... |
Do This... |
---|---|
You can edit the value of any of the choice options. |
|
You can establish different choices for parameters based on the value of an argument, so that strings are substituted that agree numerically. |
|
You can add as many alternatives as you need for different value ranges. |
|
You can type in other text in the pattern, arguments, or choices fields to see different formatting behaviors. Try it out!