Page 1 of 1

Multi-Language menu:

Posted: Mon Aug 04, 2014 11:30 am
by Hawk

I just started learning with this amazing appery.io. One of the first challenges I am facing now is with the first page (login-page). I need to create a menu of supported languages.

I found this great tutorial (http://devcenter.appery.io/tutorials/...). However, I think this tutorial teaches how to update the app langauge based on the device/browser language.

What I am looking for is that the user can choose the language of the app apart from the device language. A button once clicked shows a list of supported languages. Is that possible? would you refer me to any tutorial/reference to start with ? I deeply appreciate your help.


Multi-Language menu:

Posted: Mon Aug 04, 2014 1:17 pm
by Maryna Brodina

Hello!

It is possible - you can select language, save it into localStorage and retrieve from localStorage instead using prenavigator.language || navigator.userLanguage;/pre


Multi-Language menu:

Posted: Tue Aug 05, 2014 6:16 am
by Hawk

Great, but how to save the language into localStorage? assuming I need to test the app in the browser then using the device


Multi-Language menu:

Posted: Tue May 12, 2015 9:40 am
by Hawk

pre
//window.open('https://jtipartner.com.my', 'blank', 'location=yes');
//window.open('https://jtipartner.com.my/jdev', 'blank', 'location=yes');
var username = localStorage.getItem("username");
var password = localStorage.getItem("password");
var language = localStorage.getItem("lang");
var credentials = username + '-' + password;
var msg = language + ':' + username + '-' + password;
var lan = '';
var lan_change = '1';

//var loginWindow = window.open('https://jtipartner.com.my/jdev', '_blank', 'location=yes');

var loginWindow = window.open('https://jtipartner.com.my', '_blank', 'location=yes,clearsessioncache=yes');

loginWindow.addEventListener('loadstop', function() {

Code: Select all

 loginWindow.executeScript({ 
         code: "jQuery('input#username').val('" + username + "'), jQuery('input#password').val('" + password + "')" 
     } 

 ); 

 if (language === 'en') { 
     loginWindow.executeScript({ 

         code: "jQuery('#lang option[value=en-GB]').attr('selected','selected')" 

     }); 

 } else if (language === 'bm') { 

     loginWindow.executeScript({ 

         code: "jQuery('#lang option[value=ms-MY]').attr('selected','selected')" 

     }); 
 } else if (language === 'ch') { 

     loginWindow.executeScript({ 

         code: "jQuery('#lang option[value=zh-TW]').attr('selected','selected')" 

     }); 
 } 

 if (lan_change === '1') { 
     loginWindow.executeScript({ 

         code: "jQuery('#lang').change()" 
     }); 
     lan_change = '0'; 
 } 

 jQuery(function() { 
     setTimeout(function() { 

         loginWindow.executeScript({ 

             code: "jQuery('.loginbtn').click()" 
         }); 

     }, 5000); 
 }); 

});
/pre