Hint: your resource XML files don't have to be prepared for translation; upload them as source files to the TextUnited translation project. Alternatively, Text United can get the resource files directly from your GitHub or BitBucket repository. This approach is practical, especially if you want to have an automated process and content scanned for translation at regular intervals.
As you build your apps, remember not to hard-code any strings. Instead, declare all strings in a default strings.xml file. Strings in strings.xml file can be extracted, translated and integrated back into your app (with appropriate qualifiers) without any changes to compiled code.
If you generate images with text, put those strings in strings.xml, and regenerate the images when needed.
File Description
A string resource provides text strings for your application with optional text styling and formatting. Three types of resources can provide your application with strings:
String
XML resource that provides a single string.
String Array
XML resource that offers an array of strings.
Quantity Strings (Plurals)
XML resource that carries different strings for pluralization.
Strings files associate text in an app (the value) with another string (the key). TextUnited uses the key to identify the text in the user interface and then translates that text.
Note: A string is a simple resource referenced using the value provided in the name attribute (not the name of the XML file). So, you can combine string resources with other simple resources in one XML file under one element.

File location
res/values/filename.xml
The filename is arbitrary. The element's name will be used as the resource ID.
Ensure your apps can run adequately regardless of language or locale by providing a complete set of default resources. The app's default resources are those not marked with language or locale qualifiers, such as those stored in res/drawable/ and res/values/. If your apps attempt to load a resource unavailable in the current language or the default set, they will crash.
Whatever the default language you're using in your apps, make sure that you store the associated layouts, drawables, and strings in default resource directories without language or locale qualifiers.
Multilingual App
Suppose that your application's default language is English. Suppose also that you want to localize all the text in your application to French and most of the text in your application (everything except the application's title) to Japanese. In this case, you could create three alternative strings.xml files, each stored in a locale-specific resource directory:
-
res/values/strings.xml
It contains English text for all the application's strings, including the text for a string named title.
-
res/values-fr/strings.xml
Contain French text for all the strings, including the title.
-
res/values-ja/strings.xml
Contain Japanese text for all the strings except the title
TIPP: Design a single set of flexible layouts
As you create your layouts, please ensure that any UI elements that hold text are designed generously. It's good to allow more space than necessary for your language (up to 30% more is typical) to accommodate other languages. Also, elements should be able to expand horizontally or vertically to accommodate variations in the width and height of UI strings or input text. Your text strings shouldn't overlap borders or the screen edge in your target languages.
Images
If you keep all your default strings in a strings.xml file, you can quickly extract them for translation. If you generate images with text, put those strings in strings.xml, and regenerate the images after translation. Once the translated strings are integrated into your app with appropriate qualifiers, your app can load them without changing your compiled code.
More info:
String resources: http://developer.android.com/guide/topics/resources/string-resource.html
Localization Checklist: https://developer.android.com/distribute/tools/localization-checklist.html
Comments
0 comments
Article is closed for comments.