When internationalization is done, your apps and services are ready for localization. You can extract localizable text from your code by using a localization tool and send those files to your translation team for translation into multiple languages and locales. By importing the translated files, you’ll get string resources for your apps and services. You can still write out string resources manually, without using the localization tool.
If you create string resources manually, they should follow the formats described in the Resource Formats section. In other words, compose string resource files for multiple languages according to the format for the programming language of your apps and services. Refer to the Resource Formats section for details.
In webOS OSE, you can create string resources with the help of a localization tool, namely, loctool. See Installing the Localization Tool for its installation. The loctool makes use of XLIFF files to generate translation files and convert them to string resource files. See Using the Localization Tool for more information.
Installing the Localization Tool
webOS OSE makes use of loctool in its localization process.
You need to install Node.js before using loctool. Node.js 7.0 or higher is required.
To run the localization tool, you need to check out the localization tool repository and then install the plugins. By checking out the ilib-loctool-webos-dist repository, you can download all related plugins including loctool.
git clone https://github.com/iLib-js/ilib-loctool-webos-dist
// or to install it globally: npm install -g
Using the Localization Tool
The localization tool parses source codes along with XLIFF files and generates string resources in formats required by each programming language. Therefore, you must provide translation data in XLIFF format to use the localization tool.
The localization process using the loctool is summarized below:
Configure your project, extract all strings eligible for localization, and export them in a set of XLIFF files with loctool.
Submit the raw XLIFF files to your translator. Get back the translated files and apply them into the project again.
Generate translated string resources by using the loctool.
Detailed explanations of the entire process are given in the loctool guide page.
The following table describes the key elements and attributes of XLIFF.
<xliff> - srcLang
Source language - the code of the language, in which the text to be translated is expressed
<xliff> - trgLang
Target language - the code of the language, in which the translated text is expressed
<group> - name
Source string - the text to be translated
Target string - the translated text
The source language is defined as en-KR.
basename : The short name for the application. The right-most word of the dot-connected string of the application name becomes the basename.
If an application name is com.webos.app.home, the basename is home.
If an application name is sample, the basename is sample.
How to write XLIFF files?
When writing an XLIFF file, the value of original attribute must match the basename. In addition, the value of name attribute in group must match the type of programming language used for developing the apps or services, as follows:
Note The value of id property in project.json must be the same as xliff’s directory name.
The loctool provides a good number of plugins for a wide variety of file types and programming languages. The following table summarizes the plugins applicable for webOS development. Plugins are node modules that can be loaded into your project. When loading the plugins to your project, specify the plugin names and the project type in the plugins and projectType properties of the project.json file.
For example, the strings for French-language speakers in France need to be stored in resources/fr/FR/strings.json, while the strings for French-speaking residents of Canada stored in resources/fr/CA/strings.json.
You can use a custom name for the JSON files, but it is recommended that you use cppstrings.json for C++ and cstrings.json for C.
Basically, follow the localization guidelines of Qt. For details, refer to the Qt documentation.
If you use the localization tool (loctool), .qm files for each locale are generated in the following file name format.