2013-06-26 52 views
0

嘿,我已經得到了此代碼來檢查語言和重定向到正確的.html文件。它在Android中完美工作,但不適用於iOS。在iOS中有些不同,或者代碼有什麼問題?Phonegap /科爾多瓦:全球化不適用於iOS

請幫幫我!

代碼:

document.addEventListener("deviceready", onDeviceReady, false); 

    // Cordova is ready 
    // 
    function onDeviceReady() { 
    navigator.globalization.getPreferredLanguage(
    function (language) 
    { 
     if(language.value == "English") 
     { 
      window.location.replace("fadeE.html"); 
     } 
     else if(language.value == "Deutsch") 
     { 
      window.location.replace("fade.html"); 
     } 
     else if(language.value == "Nederlands") 
     { 
      window.location.replace("fadeN.html"); 
     } 
     else 
     { 
      window.location.replace("fadeE.html"); 
     } 
    }, 
    function() 
    { 
     alert('Error getting language\n'); 
    } 
); 

} 
+0

被重定向到英語此刻的方式,即使在設備設置爲德語或荷蘭語 –

回答

0

所有其他人,不知道爲什麼它isn't那樣工作:

的language.value是iOS的不同:

Deutsch = de 
English = en 
Niederlands = nl 
0
var userLang = navigator.language || navigator.userLanguage 

這爲我做了詭計。似乎是navigation.globalization的一些問題,至少在IOS中。 如果只想前2個字母像「恩」或「德」使用這個片段:
userLang = userLang.substr(0,2);

相關問題