From ae1a95a0fe64dc923d1704ead60364ac1863a79f Mon Sep 17 00:00:00 2001 From: Erfan Mola Date: Tue, 10 Oct 2023 07:46:57 +0330 Subject: [PATCH] Fix locale issue on LocaleProvider --- package-lock.json | 4 ++-- package.json | 2 +- src/providers/LocaleProvider.vue | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index a4e7efa..f472a59 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@erfanmola/televue", - "version": "0.1.4", + "version": "0.1.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@erfanmola/televue", - "version": "0.1.4", + "version": "0.1.5", "dependencies": { "@twa-dev/sdk": "^6.9.0", "js-crypto-hmac": "^1.0.7", diff --git a/package.json b/package.json index 5703627..1aa46bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@erfanmola/televue", - "version": "0.1.4", + "version": "0.1.5", "type": "module", "files": [ "dist" diff --git a/src/providers/LocaleProvider.vue b/src/providers/LocaleProvider.vue index 03daa22..75c566e 100644 --- a/src/providers/LocaleProvider.vue +++ b/src/providers/LocaleProvider.vue @@ -23,18 +23,19 @@ "yi", // Yiddish ]; - const direction = rtlLocales.includes(props.locale) ? 'rtl' : 'ltr'; + const finalLocale = props.locale || WebApp.initDataUnsafe.user?.language_code?.toString().toLowerCase() || 'en'; + const finalDirection = props.direction || rtlLocales.includes(finalLocale) ? 'rtl' : 'ltr'; - document.body.classList.add(direction); + document.body.classList.add(finalDirection); - provide('locale', props.locale || WebApp.initDataUnsafe.user?.language_code?.toString().toLowerCase() || 'en'); - provide('direction', props.direction || direction); + provide('locale', finalLocale); + provide('direction', finalDirection);