2016-08-18 23:49:24 -04:00
|
|
|
var lang = "en";
|
|
|
|
var userLang = navigator.language || navigator.userLanguage;
|
|
|
|
var userLangCode = userLang.split('-')[0];
|
|
|
|
var userCountryCode = userLang.split('-')[1];
|
|
|
|
var locale = $('.ui-locale');
|
|
|
|
var supportLangs = [];
|
|
|
|
$(".ui-locale option").each(function() {
|
|
|
|
supportLangs.push($(this).val());
|
|
|
|
});
|
|
|
|
if (Cookies.get('locale')) {
|
|
|
|
lang = Cookies.get('locale');
|
|
|
|
} else if (supportLangs.indexOf(userLang) !== -1) {
|
|
|
|
lang = supportLangs[supportLangs.indexOf(userLang)];
|
|
|
|
} else if (supportLangs.indexOf(userLangCode) !== -1) {
|
|
|
|
lang = supportLangs[supportLangs.indexOf(userLangCode)];
|
|
|
|
}
|
|
|
|
|
|
|
|
locale.val(lang);
|
2016-10-22 23:38:17 -04:00
|
|
|
$('select.ui-locale option[value="' + lang + '"]').attr('selected','selected');
|
|
|
|
|
2016-08-18 23:49:24 -04:00
|
|
|
locale.change(function() {
|
|
|
|
Cookies.set('locale', $(this).val(), {
|
|
|
|
expires: 365
|
|
|
|
});
|
|
|
|
window.location.reload();
|
2016-10-09 22:14:17 -04:00
|
|
|
});
|