Skip to content
Snippets Groups Projects
Commit bdc0f747 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Persist selected language via cookie across sessions

parent 2512fb7e
No related branches found
No related tags found
1 merge request!1163Resolve "Changing the language doesn't affect the Django language"
Pipeline #111374 failed
......@@ -5,7 +5,6 @@
import dateTimeFormats from "./dateTimeFormats.js";
const i18nOpts = {
locale: "en",
fallbackLocale: "en",
messages: {},
dateTimeFormats,
......
......@@ -241,8 +241,6 @@ export default {
},
watch: {
systemProperties: function (newProperties) {
this.$i18n.locale = newProperties.currentLanguage;
this.$vuetify.lang.current = newProperties.currentLanguage;
this.$vuetify.theme.themes.light.primary =
newProperties.sitePreferences.themePrimary;
this.$vuetify.theme.themes.light.secondary =
......
......@@ -5,7 +5,6 @@
nameTranslated
cookie
}
currentLanguage
sitePreferences {
themePrimary
themeSecondary
......
......@@ -9,6 +9,7 @@ import Vuetify from "@/vuetify";
import VueI18n from "@/vue-i18n";
import VueRouter from "@/vue-router";
import VueApollo from "@/vue-apollo";
import VueCookies from "@/vue-cookies";
import AleksisVue from "./plugins/aleksis.js";
......@@ -26,6 +27,7 @@ Vue.use(Vuetify);
Vue.use(VueI18n);
Vue.use(VueRouter);
Vue.use(VueApollo);
Vue.use(VueCookies);
// All of these imports yield config objects to be passed to the plugin constructors
import vuetifyOpts from "./app/vuetify.js";
......@@ -33,8 +35,20 @@ import i18nOpts from "./app/i18n.js";
import routerOpts from "./app/router.js";
import apolloOpts from "./app/apollo.js";
const i18n = new VueI18n(i18nOpts);
const vuetify = new Vuetify(vuetifyOpts);
const i18n = new VueI18n({
locale: Vue.$cookies.get("django_language")
? Vue.$cookies.get("django_language")
: "en",
...i18nOpts,
});
const vuetify = new Vuetify({
lang: {
current: Vue.$cookies.get("django_language")
? Vue.$cookies.get("django_language")
: "en",
},
...vuetifyOpts,
});
const router = new VueRouter(routerOpts);
const apolloProvider = new VueApollo(apolloOpts);
......
......@@ -587,6 +587,7 @@ YARN_INSTALLED_APPS = [
"vue-apollo@^3.1.0",
"vuetify@^2.6.7",
"vue-router@^3.5.2",
"vue-cookies@^1.8.2",
"vite@^4.0.1",
"vite-plugin-pwa@^0.14.1",
"vite-plugin-top-level-await@^1.2.2",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment