Properties

.properties files are commonly used in applications on various platforms. There is no standard for .properties files, so there might be different dialects for different APIs.

Since such files are widely used to implement the internationalization of Java projects, Lingohub has chosen to support the Java ResourceBundle dialect closely.

But by being quite tolerant and supporting other syntax features.

Format

  • Key-value pairs are delimited with the equal character =, and terminated by a new line.
    The = may be surrounded by white spaces. (Lingohub does not support : as the separator.)
  • If the value continues in the next line, the line shall end with a backslash \.
  • Newlines can be escaped by using the\n.
  • A placeholder can have the following form: {name} where the name can consist of any number of non-whitespace characters.
  • Comment lines start with a hash sign # or an exclamation mark !. Everything up to the end of the line is treated as a comment.
  • Lingohub will assign a comment to the next key-value pair. These comments will be used as segment descriptions.
  • Java defines .properties files to be encoded in ISO-8859-1. Characters not included in this character set must be masked using so-called UTF-16 escaping (\\u... and \\x...).
  • However, Linghub also allows you to use UTF-8 encoded files.
    Lingohub recommends this approach, as the files are easier for humans to read.

Examples

Additional example files can be accessed here.

# this comment will be interpreted as header comment

# the value can continue to the next line if the previous line ends with a backslash
welcome_message = Welcome back, \
we have missed you

# multi line comments belong to the next key value pair
# as long as they are not interrupted by a white line
visit_count = this is your {visit} visit to our site

! comments in .properties files can start with exclamation mark
hello_user = Hello {username}

escaped_newline = a newline can be escaped \n by using backslash n

charset.escaped.u=actually german\\: muss gr\\u00F6sser gleich {value} sein

double_quoted="Using double quotes"
single_quotes='Using single quotes"

Used by

Java

Since JDK 1.1, Java has used the class java.util.ResourceBundle to internationalize your Java applications. This implementation has slightly changed since then, but it still properly implements this approach.
On the other hand, you will find abstractions for using this ResourceBundle base in your JSP and JSF … applications.

Java based Frameworks


References