Java Properties

Extension .properties
Smartling identifier javaProperties
Example File
Resources Java Localization Documentation


Every string is created with key/variant metadata based on the keys in the file. If the keys are different for two strings with the same value, Smartling will create two strings using the key as context metadata.

String Instructions

For files using Parser version 3, Smartling will automatically ingest and display file comments as instructions for translators. The comments must immediately precede the string. For example, for the following comment:

# Back button label
"Back" = "Back";

the text "Back button label" will be captured as a file instruction.

Other Information

By default Smartling automatically captures properties that are formatted for both the MessageFormat.format and String.format methods. By default all files are parsed as if placeholder_format=JAVA and string_format=MESSAGE_FORMAT, unless some other directive is given.

string_format=MESSAGE_FORMAT uses placeholders in the syntax: {*} and the single quote (apostrophe) is an escape character, so to use the single quote character, it must be escaped as ''. When MessageFormat parsing is on (default) in your source file single quotes must be escaped as two single quotes: '' otherwise it will not be captured. If a translation has a single quote character, it will be escaped in the downloaded file as ''. Translators may use a single quote even when the original string has none. If MessageFormat is turned off then strings will not need single quotes escaping to capture them, and single quotes in translations will not be escaped. You can turn MessageFormat off and on in a single file, using inline directives.

placeholder_format=JAVA uses c-style placeholder syntax: %d, %s, %4.2f, etc. and because the % character is an escape character so displaying a single percent character literal requires that it be escaped as %% . When JAVA parsing is on (default) in your source file single percent characters must be escaped as two single percent characters: %% otherwise the % may trigger placeholder treatment and create an invalid placeholder in your string that causes incorrect capture and prevents proper translation. When JAVA parsing is on Smartling will escape the % character in a translated string if the string has a JAVA formatted placeholder. Otherwise the % character in the translation are delivered unescaped.

If this default behavior is not desirable for your content you can turn off either of the formatting treatments for the entire file or just for the strings where you don't want the behavior. You can turn the behavior off and on throughout the file as needed.

You can also specify your own custom placeholder syntax that is in addition to the standard behavior from the above two directives.

Note: When using file/get to download properties files from Smartling, the parameter includeOriginalStrings=false ensures that if no translations are available, Smartling returns an empty string. If the parameter is set to true, Smartling returns the original string.


Directive Format

# smartling.[directive_name] = [value]

The directive must be a single comment on one line, and there should not be any inline trailing symbols after the directive. Directives apply to all strings that follow them. Directives can be changed throughout the file


Values:1. Custom regular expression (pcre)
2. NONE - disable custom placeholders
Description:Used to define a custom placeholder format for strings in the file. See Placeholders in Resource Files for more information.
# smartling.placeholder_format_custom = \[.+?\]

Any characters surrounded by square brackets will be treated as a placeholder.


Description:Used to specify a standard placeholder format. See Placeholders in Resource Files for more information.
# smartling.placeholder_format = IOS

Specifies iOS-style placeholders for the file.


Values:MESSAGE_FORMAT (default) or NONE
Description:String format is a parser directive for specialized file processing that enables string escaping and pre-processing rules as defined by various third party resource handlers. The default is MessageFormat, a standard Java resource handler.
# smartling.string_format = NONE

Turns off MESSAGE_FORMAT string handling below the directive


Description:ESCAPE_UNICODE indicates that all non-Latin1 (not in range 0000 - 007F of unicode) symbols after this comment should be escaped by a \uXXXX escaping expression in the process of a file download.
# smartling.download_format = ESCAPE_UNICODE

Hello? will be escaped as Hello\u1D25 on download.


Values:int - Accepted values are 0-100
Description:Sets the percentage by which original strings are inflated when downloading pseudo translations. If this directive is not set, pseudo translations are 30 percent longer than the original strings.
# smartling.pseudo_inflation = 80

Downloaded pseudo translations will increase the length of original strings by 80 percent.


- (since Parser v3)
Values:translate OR notranslate
Description:Use this directive to enable or disable processing of translation strings in the file. You must turn translation back on after the strings you want to exclude.
# smartling.sltrans = notranslate

Strings below this directive will be captured as strings but excluded from translation

# smartling.sltrans = translate

Strings below this directive will be translated