Languages

Menu
Sites
Language
How to i18n my web app

Hi

I have many user-visible strings in all kinds of .js docs

like:"var popupText = $('<div id="popupText">Search Result</div>');"

but little in index.html.

Any ideas that how i18n my web app  simple?

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

13 Replies
Lakshmi Grandhi
can you use "lang" tag for each language. <name xml:lang="en">English Name</name> <name xml:lang="de">German Name</name>
tattoo wu
I know it's in config.xml,I can do i18n like that. But how do i18n in *.js docs or index.html doc?
Lakshmi Grandhi
event in html or js file using lang attribute. http://stackoverflow.com/questions/7076837/what-html-lang-attribute-value-should-i-use-for-a-mixed-language-page
tattoo wu
sorry,it does not apply to my code. my web app would support 26 kinds of languages. I hope it can work like android. All user-visible strings in one named *.xml or *.json doc like "en" "zh-CN" "ko" and then I can use some interface function to get the corresponding i18n string and set my code as the string, then it can show right string if I change the language of device. for example $('#sample')[0].innerHTML = "Poor"; var aaa = getMessage("xxx"); if en xxx is “Poor”, if zh-CN xxx is “穷”; so I use: $('#sample')[0].innerHTML = aaa; and I find a document useful https://developer.tizen.org/documentation/articles/localization but tizen has no "chrome.i18n.getMessage("appName")' interface?
Lakshmi Grandhi
Hi Tattoo, Tizen support globalize library for localization, you need to use globalize APIs for using in javascript. For more information and example for globalize go through below link github.com/jquery/globalize https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.web.appprogramming%2Fhtml%2Fapp_dev_process%2Flocalize_widget.htm
tattoo wu
It means that if I want i18n ten docs(include index.html and other *.js) I have to copy the ten docs to "ko" (for example) folder,and modify the user-visible strings form en to ko so if I modify index.html future ,I have to modify 26(if I support 26 kinds of language) index.html docs and other *.js docs?
Lakshmi Grandhi
Hi , The above you have mentioned are for creating packages for different languages. You can globalize string using Globalize.addCultureInfo("default", { messages: { "hello": "hello", "world": "world" } }); Globalize.addCultureInfo("es", { messages: { "world": "mundo" } }); Globalize.culture("es"); strictEqual( Globalize.localize("world"), "mundo", "Key exists in current culture 'es'"); The above example will print the text based on the language select.
tattoo wu
It seems that "Globalize" is in tizen-web-ui-fw.js? but I use jquery.js and jquery.mobile.js. Can I use "Globalize" in jquery? What should I include?
Lakshmi Grandhi
yes, tizen-web-ui-fw.js javacript has code on top of Globalize library, for jquerymobile u have to use i18Text javascript files.
Lakshmi Grandhi
can u tried adding globalize.js file in your project https://github.com/jquery/globalize/blob/master/lib/globalize.js
tattoo wu
I can use Globalize object after include globalize.js but I get "en" language whatever my system language is. the "Globalize.culture" is like this: {"name":"en","englishName":"English","nativeName":"English","isRTL":false,"language":"en",......}
Barrel

This tool is the best for web app i18n: https://poeditor.com/. You can invite translators to join your projects and they can use features such as a translation memory or they can connect to github to get files from there.

AVSukhov

Hello,

Refer following article:

http://stackoverflow.com/questions/6448451/java-web-application-i18n