To successfully localize your apps and services, you need to internationalize them first.
Internationalization mainly carries out the following two tasks: marking text strings for translation and formatting locale-sensitive data. Text strings of your apps and services need to be marked for translation. Formatting locale-sensitive data, such as dates, times, numbers or currency, for different locales and cultural conventions are also required. These are done by using an external internationalization library for each supported programming language.
Internationalization in webOS OSE is available for different programming languages. See Overview for the list of supported programming languages.
Note This page only provides guides for marking strings for translation. For more information about formatting locale-sensitive data, please refer to the user guide of the provided internationalization library for each programming language.
JavaScript
For web apps developed in JavaScript, use iLib to internationalize your code.
Enact framework offers the $L component as part of its i18n library, which provides functions to map to translated strings.
Example for $L usage
import $L, {toIString} from '@enact/i18n/$L';
$L('Close'); // => "Close" in the current locale
toIString('Close'); // => an ilib IString representing "Close" in the current locale
After that, use the ResBundle.getString() method of iLib as shown in the example below:
Example for a non-Enact web app
var ResBundle = require("ResBundle.js");
var rb =new ResBundle({locale:"en-US"});
var str = rb.getString("String 1"); // str is iLib string object
var jsStr = str.toString(); // jsStr is js string object
C++/C
If you are developing apps or services in C++/C, use libwebosi18n to internationalize your code.
The following shows an example which uses the getLocString() API of libwebosi18n in C++ and C: