20 lines
586 B
JavaScript
20 lines
586 B
JavaScript
|
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);
|
||
|
});
|
||
|
});
|
||
|
});
|