From 2cf34482a60727e90e7c6edf595e6aee8f43c056 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Feb 2022 11:21:31 +0530 Subject: [PATCH] Add RTL support --- src/App.vue | 17 +++++++++++------ src/plugins/i18n.js | 1 + src/store/i18n-store.js | 14 ++++++++++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/App.vue b/src/App.vue index 74ca3ff..a204bcd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -172,12 +172,6 @@ export default { } }, - watch: { - '$store.state.prefs.prefs.darkMode' (newVal) { - this.$vuetify.theme.dark = newVal - } - }, - methods: { changeLocale (lang) { return changeLocale(lang) @@ -192,9 +186,20 @@ export default { } }, + watch: { + '$store.state.prefs.prefs.darkMode' (newVal) { + this.$vuetify.theme.dark = newVal + }, + + '$store.state.i18n.rtl' (newVal) { + this.$vuetify.rtl = newVal + } + }, + created () { this.$store.dispatch('prefs/loadState') this.$store.dispatch('auth/initializeAuth') + this.$vuetify.rtl = this.$store.state.i18n.rtl } } diff --git a/src/plugins/i18n.js b/src/plugins/i18n.js index d4a1d16..c524985 100644 --- a/src/plugins/i18n.js +++ b/src/plugins/i18n.js @@ -31,6 +31,7 @@ export const COUNTRY_I18N_EXCEPTIONS = { 'zh-Hans': 'zh' } +// Similar switches for RTL can be found in the i18n store async function syncStylesPerLanguage (locale) { switch (locale) { // All the latin languages diff --git a/src/store/i18n-store.js b/src/store/i18n-store.js index 2367ed6..9256875 100644 --- a/src/store/i18n-store.js +++ b/src/store/i18n-store.js @@ -4,7 +4,8 @@ export const i18nStore = { fullFormatter: null, dateFormatter: null, NF: null, - timeAgo: null + timeAgo: null, + rtl: false }), mutations: { @@ -17,8 +18,17 @@ export const i18nStore = { dateStyle: 'long' }) state.NF = new Intl.NumberFormat(window.localStorage.getItem('NF_OVERRIDE') || intlLocale) - state.timeAgo = timeAgo + + switch (intlLocale) { + case 'ar': + case 'ckb': + state.rtl = true + break + default: + state.rtl = false + break + } } },