Guest User

Untitled

a guest
Dec 12th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. var win = Ti.UI.createWindow({
  2. backgroundColor: '#fff'
  3. });
  4.  
  5. var container = Ti.UI.createView({
  6. height: Ti.UI.SIZE,
  7. layout: 'vertical'
  8. });
  9.  
  10. var label1 = Ti.UI.createLabel({
  11. text: Ti.Locale.currentLanguage + ' (' + L('hello_world') + ')',
  12. color: 'black'
  13. });
  14.  
  15. var label2 = Ti.UI.createLabel({
  16. textid: 'hello_world',
  17. color: 'black'
  18. });
  19.  
  20. var btn = Ti.UI.createButton({
  21. title: 'Change'
  22. });
  23.  
  24. btn.addEventListener('click', function () {
  25. var newLang = Ti.Locale.currentLanguage == 'sv' ? 'en' : 'sv';
  26. Ti.Locale.setLanguage(newLang);
  27. label1.text = Ti.Locale.currentLanguage + ' (' + L('hello_world') + ')';
  28. label2.textid = 'hello_world';
  29. });
  30.  
  31. container.add(btn);
  32. container.add(label1);
  33. container.add(label2);
  34. win.add(container);
  35.  
  36. win.open();
  37.  
  38.  
  39.  
  40. ///////// strings.xml for en/////////////////////
  41.  
  42. <?xml version="1.0" encoding="UTF-8"?><resources>
  43. <string name="hello_world">This is a test string in English</string>
  44. </resources>
  45.  
  46.  
  47. //////////////////
  48.  
  49. ///////// strings.xml for sv/////////////////////
  50.  
  51. <?xml version="1.0" encoding="UTF-8"?><resources>
  52. <string name="hello_world">This is a test string in Swedish</string>
  53. </resources>
  54.  
  55.  
  56. //////////////////
Add Comment
Please, Sign In to add comment