ShowTable of Contents Get current langauge To get the current language of the device, use
ynGetLang()
Returns:
a two letter language code in lower case like "en" or "de".
Storing language data Strings for the YouAtNotes Framework are stored in yn/i18n/yn_i18n_<langkey>.js files as a dictionary.
Get a localized string
ynL("key1");
String.format(L("format_test"), "value");
Add your own language strings
You can add your own, application specific strings with:
ynI18N.addString(key, language, s);
With:
key: a new key for your string, for example "formLabel1".
language: a language identifier like "en" or "de" (two chars).
s: the actual string
Notes:
After adding a string, you can get the string back depending on the actual language of the device with ynL(key). Default strings' keys of the YouAtNotes Framework are prefixed with "yn", so when adding your own strings, you should avoid keys starting with "yn".
Examples Print out a string of the YouAtNotes Framework depending on the device language:
YN.log(ynL("ynCommon_1"));
Add custom strings for language de and en:
ynI18N.addString("label1", "en", "This is my label.");
ynI18N.addString("label1", "de", "Das ist mein Label.");
See also Titanium has it's own, different approach for application internationalization. It's up to you which technique you want to use.
http://developer.appcelerator.com/blog/2010/08/dealing-with-multiple-screens-and-multiple-languages.html
|