From 75771b160598419296d43f67cb73ba2a5af7a739 Mon Sep 17 00:00:00 2001 From: Elmar Kresse Date: Wed, 31 Jan 2024 15:55:27 +0100 Subject: [PATCH] fix:#5 readded missing locale function for dom --- frontend/src/i18n/index.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/src/i18n/index.ts b/frontend/src/i18n/index.ts index 54a6b70..765148b 100644 --- a/frontend/src/i18n/index.ts +++ b/frontend/src/i18n/index.ts @@ -20,6 +20,18 @@ function setup() { 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 export default { // Expose the VueI18n instance via a getter @@ -27,4 +39,5 @@ export default { return _i18n; }, setup, + setLocale, };