Allo setting UI language via query param

This commit is contained in:
N-Pex 2021-09-25 15:08:26 +02:00
parent f9745ddb7d
commit 583f6b78cd
2 changed files with 14 additions and 2 deletions

View file

@ -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.