diff --git a/frontend/src/i18n/index.js b/frontend/src/i18n/index.js index b0def2c3..84d08a7d 100644 --- a/frontend/src/i18n/index.js +++ b/frontend/src/i18n/index.js @@ -100,6 +100,8 @@ const removeEmpty = (obj) => {} ); +export const rtlLanguages = ["he", "ar"]; + const i18n = new VueI18n({ locale: detectLocale(), fallbackLocale: "en", diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index bb12a059..c2a8b957 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -12,8 +12,8 @@ import ProfileSettings from "@/views/settings/Profile"; import Shares from "@/views/settings/Shares"; import Errors from "@/views/Errors"; import store from "@/store"; -import { baseURL, name, rtlLanguages } from "@/utils/constants"; -import i18n from "@/i18n"; +import { baseURL, name } from "@/utils/constants"; +import i18n, { rtlLanguages } from "@/i18n"; Vue.use(Router); @@ -161,12 +161,13 @@ router.beforeEach((to, from, next) => { /*** RTL related settings per route ****/ const rtlSet = document.querySelector("body").classList.contains("rtl"); const shouldSetRtl = rtlLanguages.includes(i18n.locale); - // Add RTL - if (shouldSetRtl && rtlSet === false) { - document.querySelector("body").classList.add("rtl"); - //Remove RTL - } else if (rtlSet === true && shouldSetRtl === false) { - document.querySelector("body").classList.remove("rtl"); + switch (true) { + case shouldSetRtl && !rtlSet: + document.querySelector("body").classList.add("rtl"); + break; + case !shouldSetRtl && rtlSet: + document.querySelector("body").classList.remove("rtl"); + break; } if (to.matched.some((record) => record.meta.requiresAuth)) { diff --git a/frontend/src/utils/constants.js b/frontend/src/utils/constants.js index 9b81ebf3..200c4e8d 100644 --- a/frontend/src/utils/constants.js +++ b/frontend/src/utils/constants.js @@ -15,7 +15,6 @@ const enableThumbs = window.FileBrowser.EnableThumbs; const resizePreview = window.FileBrowser.ResizePreview; const enableExec = window.FileBrowser.EnableExec; const origin = window.location.origin; -const rtlLanguages = ["he", "ar"]; export { name, @@ -34,5 +33,4 @@ export { resizePreview, enableExec, origin, - rtlLanguages, }; diff --git a/frontend/src/views/settings/Profile.vue b/frontend/src/views/settings/Profile.vue index 566b62fd..4002e08c 100644 --- a/frontend/src/views/settings/Profile.vue +++ b/frontend/src/views/settings/Profile.vue @@ -75,7 +75,7 @@ import { mapState, mapMutations } from "vuex"; import { users as api } from "@/api"; import Languages from "@/components/settings/Languages"; -import i18n from "@/i18n"; +import i18n, { rtlLanguages } from "@/i18n"; export default { name: "settings", @@ -144,7 +144,9 @@ export default { singleClick: this.singleClick, dateFormat: this.dateFormat, }; - const shouldReload = data.locale != i18n.locale; + const shouldReload = + rtlLanguages.includes(data.locale) !== + rtlLanguages.includes(i18n.locale); await api.update(data, [ "locale", "hideDotfiles",