fix(i18n): load language files before doing anything else (#3218)

Resolves #3214

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: vikunja/frontend#3218
This commit is contained in:
konrad 2023-03-10 13:46:23 +00:00
parent e9d48c442d
commit 013472e899

View File

@ -39,41 +39,44 @@ if (window.API_URL.slice(window.API_URL.length - 1, window.API_URL.length) === '
window.API_URL = window.API_URL.slice(0, window.API_URL.length - 1) window.API_URL = window.API_URL.slice(0, window.API_URL.length - 1)
} }
const app = createApp(App)
app.use(Notifications)
// directives // directives
import focus from '@/directives/focus' import focus from '@/directives/focus'
import { VTooltip } from 'floating-vue' import {VTooltip} from 'floating-vue'
import 'floating-vue/dist/style.css' import 'floating-vue/dist/style.css'
import shortcut from '@/directives/shortcut' import shortcut from '@/directives/shortcut'
import cypress from '@/directives/cypress' import cypress from '@/directives/cypress'
app.directive('focus', focus)
app.directive('tooltip', VTooltip)
app.directive('shortcut', shortcut)
app.directive('cy', cypress)
// global components // global components
import FontAwesomeIcon from '@/components/misc/Icon' import FontAwesomeIcon from '@/components/misc/Icon'
import Button from '@/components/input/button.vue' import Button from '@/components/input/button.vue'
import Modal from '@/components/misc/modal.vue' import Modal from '@/components/misc/modal.vue'
import Card from '@/components/misc/card.vue' import Card from '@/components/misc/card.vue'
app.component('icon', FontAwesomeIcon) // We're loading the language before creating the app so that it won't fail to load when the user's
app.component('x-button', Button) // language file is not yet loaded.
app.component('modal', Modal) setLanguage().then(() => {
app.component('card', Card) const app = createApp(App)
app.config.errorHandler = (err, vm, info) => { app.use(Notifications)
app.directive('focus', focus)
app.directive('tooltip', VTooltip)
app.directive('shortcut', shortcut)
app.directive('cy', cypress)
app.component('icon', FontAwesomeIcon)
app.component('x-button', Button)
app.component('modal', Modal)
app.component('card', Card)
app.config.errorHandler = (err, vm, info) => {
if (import.meta.env.DEV) { if (import.meta.env.DEV) {
console.error(err, vm, info) console.error(err, vm, info)
} }
error(err) error(err)
} }
if (import.meta.env.DEV) { if (import.meta.env.DEV) {
app.config.warnHandler = (msg) => { app.config.warnHandler = (msg) => {
error(msg) error(msg)
throw(msg) throw(msg)
@ -92,21 +95,20 @@ if (import.meta.env.DEV) {
error(err) error(err)
throw err throw err
}) })
} }
app.config.globalProperties.$message = { app.config.globalProperties.$message = {
error, error,
success, success,
} }
if (window.SENTRY_ENABLED) { if (window.SENTRY_ENABLED) {
import('./sentry').then(sentry => sentry.default(app, router)) import('./sentry').then(sentry => sentry.default(app, router))
} }
app.use(pinia) app.use(pinia)
app.use(router) app.use(router)
app.use(i18n) app.use(i18n)
setLanguage().then(() => {
app.mount('#app') app.mount('#app')
}) })