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.
source share