Java Property Files
Property files have a simple structure, similar to the structure of Windows INI files.
Passolo supports all the features offered by this format, including multiline strings, empty entries, ASCII escape sequences, and UNICODE escape sequences.
Java property files can be stored in ANSI or UNICODE format, and will be generated in the same format by default after translation, using the target codepage where appropriate. You can specify a different encoding for the target files in the Java options (see Configuring the Java Add-In).
Escape sequences in source and target files
Escape sequences are character strings that cannot be entered directly into a string. For instance, a line break cannot be inserted into a string in a properties file, because it would end the string. The escape sequence '\n' is used instead. Other common escape sequences are '\r' for carriage return and "\t' for tab. Because the backslash initiates the escape sequence these cases, it cannot itself be used directly as a character. For this reason a backslash has to be inserted using the escape sequence '\\'.
In theory, every character can be inserted as an escape sequence, either as '\xhh' (value range of one byte) or '\uhhhh' (value range of one UTF-16 character). Inserting characters that can be inserted normally in this way does not make sense, but it can be used when, for instance, a character cannot be inserted directly into an ANSI file.
When Passolo reads property files, it evaluates escape sequences and replaces them with the actual characters, so that the translator does not need to worry about escape sequences. When writing, it transforms any characters that cannot be inserted directly. However these conversions are not always unique. The following escape sequences are used for line breaks: '\n', 'x0a' and '\u000a'. Usually '\n' is used. If Passolo determines that a different encoding is used in the source string, it will also use this for the target string.
The backslash is also used for empty characters that are part of a string, e.g. between an ID or a delimiter (=) that identifies a string. The same applies to empty characters that follow a string. Otherwise, simple empty characters before and after a string are deleted. The escape sequence is '\<space>'. In this case Passolo also converts the leading and trailing 'escaped' empty characters into proper empty characters that the translator can then work with as usual. When writing, it inserts the leading and trailing empty characters as escape sequences.
The final use for the backslash is as a line continuation marker in property files. A backslash at the end of a line indicates that the text in the following line belongs to the same string. Any leading and trailing empty spaces in the next line are deleted unless they are inserted as '\<space>'. Passolo processes the line continuation marker and assembles lines that belong together into one string. However, when writing, the string is output as one line and is not spread over several lines.
Metadata in Property Files
Strings can be enriched with metadata read from comments. Comments with metadata must start with '##'. The following metadata directives are supported:
- ReadOnly
- Values are true or false. This directive applies to the following string and sets or resets the ReadOnly flag for the source string in Passolo.
- MaxLen
- Numerical value. This directive applies to the following string and sets MaxLen property for the source string in Passolo. The MaxLen property value will be used to check the length of translated strings.
- Escaping
- This directive applies to all the following strings. AutoDetection is the default value and behavior. In Passolo all strings containing placeholder (like {0}) are treated as format string for messageFormat functions. Single quotes and curly braces will be escaped automatically.
If you insert ' or { in a string under one of the escaping directives, then these will be auto-propagated to all the replicates in the current translation file/ all translation files in the specific format given by the initial directive.
Example:
In NoneInMessageFormat ' or { will be auto-propagated to the replicate strings of the AutoDetection and AllInMessageFormat and written in the target file as ' or {.
If the string is edited in AutoDetection or AllInMessageFormat the ' and { will be displayed as escaped (" and '{') and written in the target file as escaped.
- Comment
-
All data following the Equal sign up to the end of the line are treated as a comment and is added to the comment property in Passolo.
Also, in case metadirectives placed on individual lines, every directive located under a comment directive will be treated as a comment and as well added in the comment property.
Comment must be the last directive because the rest of the line is not evaluated anymore.
Metadata directives can be concatenated in one line by semicolons or placed on individual lines. Directives and vales are not case sensitive.
## maxlen=20;Escaping=NoneInMessageFormat;comment=This is a comment ;=) containing fancy characters
id1=string ''with'' place holder {0}.
##maxlen=30; ReadOnly=true;
id2=string 'without' placeholder
##Escaping=NoneInMessageFormat
##Comment=This is a comment
id3=string 'without' placeholder