How is i18n handled within Sencha touch? (I am talking of localization support for strings, but also of localized components)
A more specific question: I have a form that contains a date picker, how do I make sure that the date will be displayed and picked in european format when I access the application using a french android phone?
Cheers
locale folder is under /src folder in sencha touch
For your own strings (not talking about native touch component) you could do something like this.
1) In your index.html in the head section, load a LocaleManager.js file (whatever the name) before the
<script id="microloader" type="text/javascript" src="sdk/microloader/development.js"></script>
In your localeManager, depending on your browser's language load the resource file corresponding to your language (myStrings-fr.js | myStrings-en.js )
You can do something like this to get the language in the browser:
2) Create your resources files with your translated string
It should look like this for the english version (myStrings-en.js) :
It should look like this for the french version (myStrings-fr.js) for example :
3) In your sencha touch code, for example for a searchfield place holder value
Hope it will help.
Another solution could be to modify the build process of your sencha touch app and create localized versions of your app when building it. So there would be one version per language. Then depending on the brower language you would load the right version of your app when loading the app in the browser.
There isn't an official API for i18n in SenchaTouch, yet. Although in Ext 4 there are localization files for all components in the /locale folder.
There is an old tutorial that indicates a way, by dynamically in setting the src attribute of a script tag according to the locale.
Use window.navigator.language to check the browser's language.
Locale files must be set in /ext/locale/ext-lang-fr.js
Where you can override the components properties.
I made a working prototype you can check out here:
http://lab.herkulano.com/sencha-touch/date-picker-i18n/
Here is my implementation:
I want me app to be translated to English and Spanish, based in the device's language, if the language is not Spanish, then it takes the default (English). Here are my classes:
And here is how you call it:
I hope it helps.
I wrote my own i18n class, here it is:
Then you can call it like this:
For more information, you can read the original blog post here: http://zippy1978.tumblr.com/post/36131938659/internationalization-i18n-with-sencha-touch