1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-14 20:55:57 +01:00
galene/static/scripts/index.js

30 lines
785 B
JavaScript
Raw Normal View History

// The below provided options are default.
var translator = new Translator({
defaultLanguage: "en",
detectLanguage: true,
selector: "[data-i18n]",
debug: false,
registerGlobally: "__",
persist: false,
persistKey: "preferred_language",
filesLocation: "/lang"
});
translator.fetch(["en", "oc", "fr"]).then(() => {
// Calling `translatePageTo()` without any parameters
// will translate to the default language.
translator.translatePageTo();
registerLanguageToggle();
});
function registerLanguageToggle() {
var select = document.querySelector("select");
select.addEventListener("change", evt => {
var language = evt.target.value;
translator.translatePageTo(language);
});
};
document.getElementById(translator.currentLanguage).selected = true;