fix:#5 readded missing locale function for dom

This commit is contained in:
Elmar Kresse
2024-01-31 15:55:27 +01:00
parent 9dc8df0cd2
commit 75771b1605

View File

@ -20,6 +20,18 @@ function setup() {
return _i18n; return _i18n;
} }
// Sets the active locale.
function setLocale(newLocale: any) {
_i18n.global.locale = newLocale;
setDocumentAttributesFor(newLocale);
}
function setDocumentAttributesFor(locale: any) {
const htmlElement = document.querySelector("html");
htmlElement?.setAttribute("lang", locale);
}
// Public interface // Public interface
export default { export default {
// Expose the VueI18n instance via a getter // Expose the VueI18n instance via a getter
@ -27,4 +39,5 @@ export default {
return _i18n; return _i18n;
}, },
setup, setup,
setLocale,
}; };