Tizen Developers

Menu
Sites
Language
How to localize a gear widget?

I don't understand the help document about localizing gear widget- Where and How is LANG_JSON_DATA defined?

I have not coded javascript for a while .. the help document says

"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"

then make folder for each locale and create langugae.js file (JSON data) and the runtime will load the correct locale!!

 

Responses

3 Replies
AVSukhov

Hello,

LANG_JSON_DATA - it`s global object defined in language.js for each local (ru, en, fr,....).

When the application is launched Web Runtime determines the current local and load appropriate LANG_JSON_DATA object.

Fujikawa

I found the solution.

     <script src="locales/en-us/language.js"></script>
     <script src="language.js"></script>

For this code, if "language.js" of specified language doesn't exist, "language.js" of en-us is used and works.

AVSukhov

Hello,

You need to create "locales" folder in your project.

In this folder create subfolders for each language (f.e. "en", "ru", "fr".......) 

In each folder create "language.js":

f.e. language.js in "en" folder:

LANG_JSON_DATA=
{
   "hello": "hello"
}

language.js in "ru" folder:

LANG_JSON_DATA=
{
   "hello": "привет"
}

 

After this load language resources to your index.html:

<script src="language.js"></script>

and use in your code, f.e.:

console.log(LANG_JSON_DATA["hello"]);

That`s all.