sutty/public/client_site_i18n.js

20 lines
586 B
JavaScript
Raw Normal View History

2020-08-01 00:06:26 +00:00
document.addEventListener('DOMContentLoaded', function() {
const available_locales = ["es","en"];
let current_locale = navigator.languages.map(function(language) {
language.split('-')[0];
}).find(function(locale) {
return available_locales.includes(available_locales);
});
if (current_locale == undefined) current_locale = available_locales[0];
available_locales.forEach(function(locale) {
if (locale == current_locale) return;
document.querySelectorAll('[lang='+locale+']').forEach(function(el) {
el.parentNode.removeChild(el);
});
});
});