Reputation: 1058
Is there a way to detect the language of your users (on an iPhone web app), but not by using the ip or the gps location ? I know it's very annoying when you go for example to turkey, and you're apps are in turkish… So… How can i really detect the language of the system ??
Is it possible in javascript ?
I should want if it's english, the web app uses eng.js for dutch dut.js and further…
Thanks
Upvotes: 4
Views: 1303
Reputation: 3651
I suppose you can do a window.navigator.language
in Javascript.
I suggest you name your files by using the ISO standard for languages; like 'en_US.js' for English (US) and 'nl_NL.js' for Dutch. That would make things easier when using window.navigator.language
:
(function(){
var s = document.getElementsByTagName('script')[0];
var lang = document.createElement('script');
lang.type = 'text/javascript';
lang.async = true;
lang.src = '/languages/' + window.navigator.language + '.js';
s.parentNode.insertBefore(lang,s);
})();
You should however do a check if the 'window.navigator.language.js'-file exists or not.
Upvotes: 4