Allo setting UI language via query param
This commit is contained in:
parent
f9745ddb7d
commit
583f6b78cd
2 changed files with 14 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ import Vue from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import vuetify from './plugins/vuetify';
|
import vuetify from './plugins/vuetify';
|
||||||
import store from './store'
|
import store from './store'
|
||||||
|
import i18n from './plugins/lang';
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import matrix from './services/matrix.service'
|
import matrix from './services/matrix.service'
|
||||||
import navigation from './services/navigation.service'
|
import navigation from './services/navigation.service'
|
||||||
|
|
@ -14,7 +15,6 @@ import VueResize from 'vue-resize';
|
||||||
import 'vue-resize/dist/vue-resize.css';
|
import 'vue-resize/dist/vue-resize.css';
|
||||||
import VueClipboard from 'vue-clipboard2'
|
import VueClipboard from 'vue-clipboard2'
|
||||||
import VueSanitize from "vue-sanitize";
|
import VueSanitize from "vue-sanitize";
|
||||||
import i18n from './plugins/lang';
|
|
||||||
|
|
||||||
var defaultOptions = VueSanitize.defaults;
|
var defaultOptions = VueSanitize.defaults;
|
||||||
defaultOptions.disallowedTagsMode = "recursiveEscape";
|
defaultOptions.disallowedTagsMode = "recursiveEscape";
|
||||||
|
|
@ -155,8 +155,8 @@ Vue.use(navigation, router);
|
||||||
new Vue({
|
new Vue({
|
||||||
vuetify,
|
vuetify,
|
||||||
store,
|
store,
|
||||||
router,
|
|
||||||
i18n,
|
i18n,
|
||||||
|
router,
|
||||||
matrix,
|
matrix,
|
||||||
config,
|
config,
|
||||||
cleaninsights,
|
cleaninsights,
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,18 @@ router.beforeEach((to, from, next) => {
|
||||||
var authRequired = !publicPages.includes(to.path);
|
var authRequired = !publicPages.includes(to.path);
|
||||||
const loggedIn = router.app.$store.state.auth.user;
|
const loggedIn = router.app.$store.state.auth.user;
|
||||||
|
|
||||||
|
if (to.query && to.query.lang) {
|
||||||
|
// Set language via query param
|
||||||
|
const lang = to.query.lang;
|
||||||
|
// Check if valid translation
|
||||||
|
if (router.app.$i18n.messages[lang]) {
|
||||||
|
router.app.$store.commit('setLanguage', lang);
|
||||||
|
if (router.app.$i18n) {
|
||||||
|
router.app.$i18n.locale = to.query.lang;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (to.name == 'Chat' || to.name == 'Join') {
|
if (to.name == 'Chat' || to.name == 'Join') {
|
||||||
if (!to.params.roomId && to.hash) {
|
if (!to.params.roomId && to.hash) {
|
||||||
// Public rooms start with '#', confuses the router. If hash but no roomId param, set it.
|
// Public rooms start with '#', confuses the router. If hash but no roomId param, set it.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue