How to identify web application for iPhone?

Is there a way to detect the language of your users (in the iPhone web application), but not using the ip or gps address? I know that it is very annoying when you go, for example, to a turkey, and you go to Turkish ... So ... How can I really recognize the language of the system?

Is this possible in javascript?

I need, if it's English, the web application uses eng.js for the Dutch dut.js and more ...

thanks

+4
source share
1 answer

I assume you can do window.navigator.language in Javascript.

I suggest you name your files using the ISO standard for languages; for example, "en_US.js" for English (USA) and "nl_NL.js" for the Dutch. This will facilitate the use of 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); })(); 

However, you should check if the file 'window.navigator.language.js' exists or not.

+4
source

All Articles