Open iriejoy opened 9 years ago
Thanks. It helped me.
I personally used the line if (langs.includes(langCode))
to keep using JavaScript.
Based on the MDN docs.
@raphaelchalicarne link is broken
@raphaelchalicarne link is broken
@dakk I updated the link
In my case I test in XP chrome. but the:
I will pass the language later by cookie or server
//langCode = navigator.language.substr (0, 2);
langCode = 'it';
EVERYTIME GIVE ME FALSE
if (langCode in langs)
$.getJSON('lang/'+langCode+'.json', translate);
else
$.getJSON('lang/en.json', translate);
instead use Jquery (already loaded)
if ($.inArray( langCode, langs ) >= 0)
base on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in