refactor(wip): translation module #135

This commit is contained in:
0xJacky 2023-08-27 14:07:28 +08:00
parent 6ede443bbe
commit 8cc71942c8
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0
11 changed files with 439 additions and 232 deletions

View file

@ -5,6 +5,7 @@ import {ref, watch} from 'vue'
import {useSettingsStore} from '@/pinia'
import {useRoute} from 'vue-router'
import http from '@/lib/http'
const settings = useSettingsStore()
@ -13,7 +14,19 @@ const route = useRoute()
const current = ref(gettext.current)
const languageAvailable = gettext.available
function init() {
if (current.value !== 'en') {
http.get('/translation/' + current.value).then(r => {
gettext.translations[current.value] = r
})
}
}
init()
watch(current, (v) => {
init()
settings.set_language(v)
gettext.current = v
// @ts-ignored