1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-23 00:55:58 +01:00
galene/static/scripts/index.js
2021-08-26 20:39:18 +02:00

29 lines
785 B
JavaScript

// 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;