add i18n to frontend, still incomplete, but a start

This commit is contained in:
dni ⚡
2023-04-13 09:32:12 +02:00
parent 8ee6be30eb
commit 8c3b4a87b1
14 changed files with 634 additions and 206 deletions
+19
View File
@@ -1,6 +1,14 @@
/* globals crypto, moment, Vue, axios, Quasar, _ */
Vue.use(VueI18n)
window.LOCALE = 'en'
window.i18n = new VueI18n({
locale: window.LOCALE,
fallbackLocale: window.LOCALE,
messages: window.localisation
})
window.EventHub = new Vue()
window.LNbits = {
api: {
@@ -320,6 +328,7 @@ window.LNbits = {
}
window.windowMixin = {
i18n: window.i18n,
data: function () {
return {
g: {
@@ -335,6 +344,10 @@ window.windowMixin = {
},
methods: {
changeLanguage: function (newValue) {
window.i18n.locale = newValue
this.$q.localStorage.set('lnbits.lang', newValue)
},
changeColor: function (newValue) {
document.body.setAttribute('data-theme', newValue)
this.$q.localStorage.set('lnbits.theme', newValue)
@@ -364,6 +377,12 @@ window.windowMixin = {
}
this.g.allowedThemes = window.allowedThemes ?? ['bitcoin']
let locale = this.$q.localStorage.getItem('lnbits.lang')
if (locale) {
window.LOCALE = locale
window.i18n.locale = locale
}
addEventListener('offline', event => {
this.g.offline = true
})