Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var win = Ti.UI.createWindow({
- backgroundColor: '#fff'
- });
- var container = Ti.UI.createView({
- height: Ti.UI.SIZE,
- layout: 'vertical'
- });
- var label1 = Ti.UI.createLabel({
- text: Ti.Locale.currentLanguage + ' (' + L('hello_world') + ')',
- color: 'black'
- });
- var label2 = Ti.UI.createLabel({
- textid: 'hello_world',
- color: 'black'
- });
- var btn = Ti.UI.createButton({
- title: 'Change'
- });
- btn.addEventListener('click', function () {
- var newLang = Ti.Locale.currentLanguage == 'sv' ? 'en' : 'sv';
- Ti.Locale.setLanguage(newLang);
- label1.text = Ti.Locale.currentLanguage + ' (' + L('hello_world') + ')';
- label2.textid = 'hello_world';
- });
- container.add(btn);
- container.add(label1);
- container.add(label2);
- win.add(container);
- win.open();
- ///////// strings.xml for en/////////////////////
- <?xml version="1.0" encoding="UTF-8"?><resources>
- <string name="hello_world">This is a test string in English</string>
- </resources>
- //////////////////
- ///////// strings.xml for sv/////////////////////
- <?xml version="1.0" encoding="UTF-8"?><resources>
- <string name="hello_world">This is a test string in Swedish</string>
- </resources>
- //////////////////
Add Comment
Please, Sign In to add comment