The Resource Bundle can be in either ASCII or
plain Unicode. The "endianess" used in the file will be determined by the
byte-order-mark (BOM) as the first character in the file, the rest of the file will be
read in accordingly. The presence of the BOM is also used to determine if the file is in
Unicode.
An explicit Unicode sequence (i.e. \uxxxx where "xxxx" is the Unicode
codepoint in hexadecimal) can also be used in the resource bundle (whether in ASCII or
Unicode).
The format is as follows:
locale {
key1 {value1}
key2 {value2}
}
The keys are used to retrieve the value later. You may not have multiple instances of
the same key.
Four value types are supported. These are solitary strings, comma-delimited lists of
strings, 2-dimensional arrays of strings, and tagged lists of strings.
Note that all values are textual. Quotes are only necessary around text that contains
spaces or other characters (such as braces or commas) that mean something to the
resource-file parser. Two quoted strings separated only by whitespace are merged into a
single string, allowing a way to split a long string across multiple lines in the resource
file. For example,
foo {
"Fourscore and 7 years ago, our fathers brought forth upon this continent "
"a new nation, conceived in liberty and dedicated to the proposition that",
"all men are created equal."
}
is a list containing two strings: "Fourscore and 7 years ago ... to the
proposition that" and "all men are created equal." Note the missing comma
at the end of the first line. Also note the space inside the quotes at the end of the
first line. This is necessary. The parser doesn't automatically insert whitespaces, so
without the space at the end of the first line, you'd get "...upon this continenta
new nation..." More than two quoted strings in a row separated only by whitespace are
concatenated in the same way.
Whitespace is ignored, as in a C source file.
Solitary strings have the format:
Key { Value }
This is indistinguishable from a comma-delimited list with only one element, and in
fact may be retrieved as such (as an array, or as element 0 or an array).
Comma-delimited lists have the format:
Key { Value, Value, Value }
Parsing is lenient; a final comma, after the last element, is allowed but not
necessary.
Tagged lists have the format:
Key { Subkey { Value } Subkey { Value } }
Specifying the subkey retrieves value.
Two-dimensional arrays have the format:
Key {
{ r1c1, r1c2, ..., r1cm },
{ r2c1, r2c2, ..., r2cm },
...
{ rnc1, rnc2, ..., rncm }
}
Where n is the number of rows, and m is the number of columns. Parsing is lenient (as
in other value types). A final comma is always allowed after the last element; either the
last string in a row, or the last row itself. Furthermore, since there is no ambiguity,
the commas between the rows are entirely optional. (However, if a comma is present, there
can only be one comma, no more.) It is possible to have zero columns, as follows:
Odd { {} {} {} } // 3 x 0 array
But it is impossible to have zero rows. The smallest array is thus a 1 x 0 array, which
looks like this:
Smallest { {} } // 1 x 0 array
The array must be strictly rectangular; that is, each row must have the same number of
elements.