How to select the file depending on the browser language in sencha touch 2? I have 3 files app_de.js, app_en-US.js and app_es.js under my project. I am finding the browser language and loading the file like this:
<script type="text/javascript" id="extlocale">
var browserLang = window.navigator.language; // get the browsers language
alert(browserLang);
var locale = 'en'; // default locale
if(browserLang == 'de' || browserLang == 'de-de') //called when the language is german
{
locale = 'de';
}
else if(browserLang == 'en-US' || browserLang == 'en-us' || browserLang == 'en')
{
locale = 'en-US'; //called when the language is english
}
else if(browserLang == 'es' || browserLang == 'es-es' )
{
locale = 'es'; //called when the language is spanish
}
else
{
console.log("Invalid language");
locale = 'en-US';
}
if(locale) {
Ext.fly('extlocale').set({src:'app_'+locale+'.js'});
}
</script>
The files will work individually if i include it this way:
<script type="text/javascript" src="app_en-US.js"></script>
Please let me know how to load the file depending on the browser's language?