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
|
|
@ -87,6 +87,18 @@ router.beforeEach((to, from, next) => {
|
|||
var authRequired = !publicPages.includes(to.path);
|
||||
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.params.roomId && to.hash) {
|
||||
// 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