Preparing Content for Translation

Java Properties

 

Extension .properties
Smartling Identifier javaProperties
Example File (see example below)
Resources Java Localization Documentation

 

Java properties example file:

#Global
selfservice.global.buttons.ok = Ok
selfservice.global.buttons.cancel = Cancel
selfservice.global.buttons.save = Save
selfservice.global.buttons.saveChanges = Save Changes
selfservice.global.buttons.close = Close
selfservice.global.buttons.edit = Edit
selfservice.global.buttons.enable = Enable
selfservice.global.buttons.disable = Disable
selfservice.global.buttons.next = Next
selfservice.global.buttons.continue = Continue
selfservice.global.buttons.back = Back
selfservice.global.buttons.finish = Finish
selfservice.global.state.on = On
selfservice.global.state.off = Off

# Menus
selfservice.menu.settings.title=Settings
selfservice.menu.settings.subtitle=Settings
selfservice.menu.settings.languageSelector=Language Selector
selfservice.menu.settings.siteOwnerInfo=Site Owner Information

# Welcome
selfservice.intro = Hello {0}, welcome

Keys - Variants

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. It is invalid to have the same key in a single resource file, though Smartling will not report any errors for such a file.

Formatting and Escaping

Review the Formatting and Escaping section and carefully review your source files and test the round-trip with Smartling using Pseudo Translation download to determine the correct integration before you begin translating with strings from Java Properties files.

When capturing strings from a Java Properties file Smartling assumes that the strings are being used for Format and MessageFormat. This has two specific implications for how we capture and deliver strings, and handle automatic integration of variables as placeholders.

The default behavior is the same as if you integrated with the following commands

placeholder_format=JAVA
string_format=MESSAGE_FORMAT

placeholder_format=JAVA implies that the strings are being formatted using java.util.Formatter. A string using that class will have standard c-style/printf format specifiers for variables and bebecause those variables use the percent char ‘%’ to mark them, when you want an actual percent character to display in your string you must escape it as ‘%%’ (both in the original and in translated strings).

string_format=MESSAGE_FORMAT implies that the strings are being formatted using java.text.MessageFormat. A string using that class will have FormatElements in curly braces and because the single quote character is used to escape the special characters { and } a single quote that you want to appear as a character must be escaped as ‘’ (both in the original and in translated strings)

The most frequent integration issues encountered in Smartling when using java properties files is caused by not integrating your file to get the behavior needed for the strings in regards to placeholder formatting and special character escaping.

For example, if your original file has:

string=Your subscription is %d% off.

The string captured by Smartling will have incorrect placeholder integration and not be correctly translatable. Strictly speaking “% o” is a valid format specifier. There are two ways to avoid this integration issue.

If your strings are formatted by Formatter, the % should be escaped in your resource file:

string1=Your subscription is %d%% off.

Conversely if you have a string like this:

string=Your subscription is 50% off.

That is NOT being formatted by Formatter Smartling will still identify a placeholder (‘% o’) for the same reason. To avoid this string being captured with a placeholder, turn off the formatting and then turn it back on if you need subsequent strings to be captured ready for formatting:

smartling.placeholder_format=NONE
string=Your subscription is 50% off.
#smartling.placeholder_format=JAVA

With this integration the string will be captured without a placeholder, and assuming the % char is still present in the translation it will not be escaped as %% when you download the translated files.

Similar issues are seen for the MessageFormat behavior. If your source file has this string which will be passed through MessageFormat:

string1=You can't delete {0}.

The ‘ should be escaped if it’s passing through MessageFormat:

string1=You can''t delete {0}

Similarly if you have a string with the literal characters { } or the ‘ character that is NOT passing through MessageFormat:

string1=You can't delete it. {We won't let you!}

You can ensure proper capture and delivery of the translation by turning off MessageFormat and then turning it back on when needed after the string to insure subsequent strings get MessageFormat treatment:

smartling.string_format=NONE
string1=You can’t delete it. {We won’t let you!}
# smartling.string_format=MESSAGE_FORMAT

When integrating the directives “inline” in your file once your set a directive it will apply to all subsequent strings. So for example, if you know your file is entirely made of strings that require MESSAGE_FORMAT but not JAVA formatting you can place the following at the top of your file:

smartling.string_format=MESSAGE_FORMAT

smartling.placeholder_format=NONE

Remember that this behavior will be true for capturing strings and delivering translations. It is very common for translators to use the single quote character as part of their translation even when the original language string did not have any quote characters.

We recommend uploading your complete set of Java Properties files and then downloading the pseudo translation, and then use that to bring up your application with the pseudo localization to check for any issues or errors.

See Placeholders in Resource Files for more on placeholders.

String Instructions

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

For example, for the following comment, the text “Back button label” will be captured as a file instruction.

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

Return Untranslated Strings as Empty

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.

Directives

Format

# smartling.[directive_name] = [value]

 

entity_escaping

Exact delivery depends on file type.

Values auto (default)
true (or yes)
false (or no)
Description Can control whether or not characters will be "escaped" into entities when delivering translations. This can be set universally for the whole file via API, or by setting the directive at the top/start of the file. The directive can also be placed inline to control the behavior of specific strings.
Examples

To use inline:
<!-- smartling.entity_escaping = false -->

String:
<!-- smartling.entity_escaping = auto -->

 

For example, your translation might look like this:
Smartling HTML escaping < > & " example string4

By default, using the "auto" setting, we would assume this is HTML from the <hr> tag and it would be converted to:
Smartling HTML escaping &lt; &gt; &amp; &quot; example string4

Using smartling.entity_escaping = false would allow Smartling HTML escaping < > & " example string4 to appear as it should.

placeholder_format

Values NONE; C; IOS; PYTHON; JAVA; YAML; QT, RESX 
Description Used to specify a standard placeholder format. 
Examples

# smartling.placeholder_format = IOS

Specifies iOS-style placeholders for the file.

 

 

placeholder_format_custom

Values 1) Custom Perl compatible regular expression.
2) NULL - disables any current custom placeholders 
Description Specifies a custom placeholder format. Any text in your file matching the regular expression you provide will be captured as a placeholder.. 
Examples

# smartling.placeholder_format_custom = \[.+?\]

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

 

 

pseudo_inflation

Values integer - 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. 
Examples

# smartling.pseudo_inflation = 80

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

 

 

string_format

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. 
Examples  

 

download_format

Values NONE (default) OR ESCAPE_UNICODE
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. 
Examples

# smartling.download_format = ESCAPE_UNICODE

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

 

 

sltrans

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. 
Examples

# 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.

 
Was this article helpful?