added dummy locale menu

This commit is contained in:
Grzegorz Leoniec 2018-12-17 21:58:27 +01:00
parent cb1815b560
commit 2679cddb45
No known key found for this signature in database
GPG Key ID: 3AA43686D4EB1377

View File

@ -8,6 +8,22 @@
>
<ds-logo />
</a>
<!-- TODO: replace with better menu (maybe footer?) -->
<a
v-if="$i18n.locale() === 'en'"
href="#"
@click="changeLanguage('de')"
>
Deutsch
</a>
<a
v-else
href="#"
@click="changeLanguage('en')"
>
English
</a>
<!-- TODO: end of dummy locale menu -->
<template v-if="isLoggedIn">
<no-ssr>
<v-popover
@ -105,6 +121,18 @@ export default {
clearTimeout(mouseLeaveTimer)
},
methods: {
changeLanguage(locale) {
// TODO: make it a component
// check if the locale has already been loaded
if (this.$i18n.localeExists(locale)) {
this.$i18n.set(locale)
return
}
import(`~/locales/${locale}.json`).then(res => {
this.$i18n.add(locale, res)
this.$i18n.set(locale)
})
},
toggleMenu() {
this.isPopoverOpen = !this.isPopoverOpen
},