timetracker update

This commit is contained in:
Daniel Goc
2026-03-11 09:33:36 +01:00
parent bbf8a2c133
commit 9ef4bb219b
121 changed files with 4328 additions and 2231 deletions

View File

@@ -1,12 +1,11 @@
import { useFetchJson } from '@/composable/useFetchJson'
import { langs } from '@/router/langs'
import type { Resp } from '@/types'
import { getLangs } from '@/utils/fake'
import { initLangs, langs } from '@/router/langs'
import { watch } from 'vue'
import { createI18n, type LocaleMessageValue, type PathValue, type VueMessageType } from 'vue-i18n'
import { createI18n, type PathValue } from 'vue-i18n'
// const x =
await initLangs()
export const i18ninstall = createI18n({
legacy: false, // you must set `false`, to use Composition API
locale: 'en',
@@ -30,18 +29,22 @@ export const i18n = i18ninstall.global
let downloadedLangs = [] as string[]
const getLangs = async (l: string) => {
if (!downloadedLangs.includes(l)) {
const lang = langs.find((x) => x.iso_code == l)
if (!lang) return
downloadedLangs.push(l)
const res = await useFetchJson<any>(`/api/v1/translations?lang_id=${lang?.id}&scope=backoffice`)
i18n.setLocaleMessage(l, res.items[lang.id]['backoffice'])
}
}
getLangs(i18n.locale.value)
watch(
i18n.locale,
async (l) => {
if (!downloadedLangs.includes(l)) {
const lang = langs.find((x) => x.iso_code == l)
if (!lang) return
downloadedLangs.push(l)
const res = await useFetchJson<any>(`/api/v1/translations?lang_id=${lang?.id}&scope=backoffice`)
// console.log(res.items[lang.id as number]['backoffice'])
i18n.setLocaleMessage(l, res.items[lang.id]['backoffice'])
}
},
{},
await getLangs(l)
}
)