Java properties
Java .properties resource bundles: flat key=value lines with Java's escaping.
| Format | Identifier | Extension |
|---|---|---|
| Java properties | java_properties | .properties |
The format java.util.Properties and ResourceBundle read, also used by Spring's messages_{locale}.properties.
# Home screen
home.title=Bon retour
home.greeting=Bonjour, {0} !
cart.summary = Vous avez {0} articles \
dans votre panierKeys
Each logical line is one key. The whole left-hand side is the key name, dots included; keys are never nested.
- The separator is
=,:or the first run of whitespace. Whitespace around an=or:is ignored. - A line whose first non-blank character is
#or!is a comment and is not imported. - A line ending in an odd number of backslashes continues on the next line. The backslash is dropped, and so is the next line's leading whitespace.
- A key that appears twice is an error.
Escapes
Import decodes \n, \t, \r, \f, \\, \uXXXX, and the escaped separators \=, \:, \#, \! and \ (space). Any other backslash is dropped, as Java does. A malformed \u escape is an error.
The file must be UTF-8. Older files that store accented characters as raw Latin-1 bytes are rejected; files that use \uXXXX escapes for them are plain ASCII and read fine.
Plurals
Properties files have no plural construct. Plural keys are left out of an export. A MessageFormat choice pattern ({0,choice,0#no files|1#one file|1<{0} files}) is an ordinary string and is written back unchanged.
Placeholders
MessageFormat arguments ({0}, {1,number}) and %s-style specifiers are kept as written. See Placeholders.
Export
Each key is written as key=value on its own line, in byte order. The output is pure ASCII, so it loads under a Latin-1 reader too:
- Backslashes, tabs, newlines, carriage returns and form feeds are escaped, as are
=,:,#and!, and spaces that are leading or inside the key. - Every character above U+007F, and the remaining control characters, is written as
\uXXXX(characters outside the Basic Multilingual Plane as a surrogate pair).
Comments are not kept.