Preparing Content for Translation

Android XML

 

Extension .xml
Smartling Identifier android
Resources Android String Resources
Android Localization

Smartling supports the Android XML resource file format. When uploading an Android XML file, make sure to specify that it is an android file, so it is not parsed as a custom XML file.

Keys-Variants

Every string is created with key/variant metadata, which is the value of the string.name attribute. If the value of two strings is the same, but the string.name attribute is different, Smartling creates two strings.

String Instructions

String instructions can be set using the instruction_comments_enabled and instruction_attributes directives

If instruction_comment_enabled is turned on any XML comment that immediately precedes a string is captured as the Instruction for that string.

Android Comments -> Smartling Instructions

<?xml version="1.0" encoding="UTF-8"?>
<!-- smartling.instruction_comments_enabled = on -->
<resources>
     <!-- It's instruction for string1 -->
     <string name="string1">string1</string>
     <!-- It's not instruction for string2 -->
     <string name="string2">string2</string>
     <!-- It's instruction for string3 --><string name="string3">string3</string>
     <!-- It's multiline -->
     <!-- instruction for string4 -->
     <string name="string4">string4</string>
     <!-- Instruction for plurals -->
     <plurals name="Nsongs">
        <item quantity="one">a song</item>
        <item quantity="other">%s songs</item>
     </plurals>
<!-- smartling.instruction_comments_enabled = off -->
     <!-- It's just comment for string5 -->
     <string name="string1">string5</string>
</resources>

If instruction_attributes is configured with some valid XML element attributes, then the value of that attribute is captured as the instruction for that string.

Android string attributes -> Smartling string instruction

<?xml version="1.0" encoding="UTF-8"?>
<!-- smartling.instruction_attributes = comment, note -->
<resources>
     <string name="string1" comment="comment for String01">String01</string>
     <string name="string2" note="note for String02">String02</string>
     <string name="string3" comment="comment for String03" note="note for         String03">String03</string>
     <!-- smartling.instruction_attributes = -->
     <string name="string5" comment="comment for String05 - not  instruction">String05</string>
     <!-- smartling.instruction_attributes = alert -->
     <string name="string6" alert="note for String06">String06</string>
     <plurals name="Nsongs" alert="Instruction for NSongs">
        <item quantity="one">a song</item>
        <item quantity="other">%s songs</item>
     </plurals>
     <string-array name="items_array" alert="instruction for items">
        <item>item1</item>
        <item alert="instruction for item2">item2</item>
        <item>item3</item>
     </string-array>
</resources>

Excluding Strings from Translation

To exclude a string from translation use the translatable="FALSE" attribute and value in the string tag:

Android XML:

<string name="string_11" translatable="FALSE">
     This android string has been marked not to be translated using the translatable attribute.
</string>


When downloading translated Android XML files via the File API, setting the parameter includeOriginalStrings=false can only strip strings that are intended for translation, but not yet translated.

Standard Placeholder Format

By default, Smartling recognizes Java-style placeholders in Android XML files. See Placeholders in Resource Files for more on placeholders.

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_custom

Values 1. Custom [Perl compatible regular expression](http://www.pcre.org/).
2. NONE - 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.

 

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.


instruction_comments_enabled

Values true OR false
Description If this directive is set to true, any comment in the file is ingested as an instruction for the next string.

 

instruction_attributes

Values Name of an attribute of a string or plurals nodes in your file.
Description Sets attributes of content nodes to be captured as file instructions for strings.

 

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.

 

character_limit

Values integer or NONE
Description Sets or removes the maximum characters allowed for a translation. If NONE is specified, character limits will be removed.
Examples

<!-- smartling.character_limit = 25 -->

The directive should go directly before the string where the character limit should be applied. This will apply a character limit of 25 to the string on the line after the directive.

<!-- smartling.character_limit = NONE -->

This will remove any character limits set for a string even if the character limit was set manually in the Dashboard.

 
Was this article helpful?