Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Multi-Language menu:

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.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Multi-Language menu:

Hello!

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

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Multi-Language menu:

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

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Multi-Language menu:

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

Return to “Issues”