Localization
By localizing your application, you can ensure that your application works around the world in different locales.
This feature is optional.
To localize a Tizen Web application:
-
Create a directory for each locale, follow these steps.
Create a directory for each locale that has localized content under the
localesdirectory in package root. The locale names are defined in the W3C IANA Language Subtag Registry.The Web Runtime loads the proper resource for the current locale according to the W3C widget using the following mark-up:
┬index.html └locales └en └language.js └ko └language.js -
Create a common JS object for language strings.
Define a global JS object in the resource file. In the following example, the JS object is
LANG_JSON_DATA. This object defines the key-value pairs for localized strings.en/language.js:LANG_JSON_DATA = { 'hello': 'hello' }ko/language.js:LANG_JSON_DATA = { 'hello': '안녕' }
“hello” is the key for the localized string, to be replaced by the value from the appropriate language.
-
Load language resources.
To load language resources, add the
<script>element containing the language resource file in yourindex.htmlfile:<script src="language.js"></script>The Web Runtime loads the
language.jsfile for the current locale and you can use the defined string element to display localized content. For example:log('hello=' + LANG_JSON_DATA['hello']);Note
When the Web Runtime fails to find a file in a local folder, it searches for the file according to the procedure in the W3C specification. If the Web Runtime still fails to find a file in a local folder, it retrieves the folders that match the parent subtag, and prioritizes the files in the subfolders over the files in the local folders closer to the root of the widget package. If after all this, the Web Runtime still cannot find the file, an unexpected problem can occur.
To avoid problems, leave a default file in the root folder.The following table lists the acceptable locale folder names.
Table: Locale folder names
Language Folder name Albanian sq-alArabic ar-aeArmenian hy-amAssamese as-inAzerbaijani az-azBasque eu-esBengali bn-inBulgarian bg-bgCatalan ca-esChinese Simplified (China) zh-cnChinese Traditional (Hong Kong) zh-hkChinese Traditional (Taiwan) zh-twCroatian hr-hrCzech cs-czDanish da-dkDutch nl-nlDutch (Belgium) nl-beEnglish (UK) en-gbEnglish (US) en-usEnglish (Australia) en-auEnglish (Canada) en-caEnglish (Ireland) en-ieEnglish (New Zealand) en-nzEnglish (Philippines) en-phEnglish (South Africa) en-zaEstonian et-eeFarsi fa-irFilipino tl-phFinnish fi-fiFrench (Canada) fr-caFrench (France) fr-frFrench (Belgium) fr-beFrench (Switzerland) fr-chGalician gl-esGeorgian ka-geGerman de-deGerman (Switzerland) de-chGerman (Austria) de-atGreek el-grGujarati gu-inHebrew he-ilHindi hi-inHungarian hu-huIcelandic is-isIndonesian id-idIrish ga-ieItalian it-itJapanese ja-jpKannada kn-caKazakh kk-kzKhmer km-khKorean ko-krLao lo-laLatvian lv-lvLithuanian lt-ltMacedonian mk-mkMalay ms-mwMalayalam ml-myMarathi mr-inMyanmar my-mmNepali ne-npNorwegian nb-noOdia or-inPolish pl-plPortuguese (Brazil) pt-brPortuguese (Portugal) pt-ptPunjabi pa-pkRomanian ro-roRussian ru-ruSerbian sr-rsSinhala si-lkSlovakian sk-skSlovenian sl-siSpanish (Spain) es-esSpanish (Latin America) es-usSwedish sv-seTamil ta-inTelugu te-inThai th-thTurkish tr-trUkrainian uk-uaUrdu ur-pkUzbekistan uz-uzVietnamese vi-vn
Related information
- Dependencies
- Tizen 2.4 and Higher