i18n refactoring, locale loaders, custom strings, fix #231

This commit is contained in:
lesion
2023-02-07 17:44:23 +01:00
parent a36c8c29cb
commit 98f6b9618c
7 changed files with 61 additions and 34 deletions

View File

@@ -1,5 +1,8 @@
export default function ({ $axios, store }) {
if (process.client) {
$axios.defaults.baseURL = window.location.origin + '/api'
$axios.setBaseURL(window.location.origin + '/api')
} else {
const config = require('../server/config')
$axios.setBaseURL(config.baseurl + '/api')
}
}

View File

@@ -1,36 +1,8 @@
export default async ({ app, store, res, $vuetify }) => {
export default async ({ app, $vuetify }) => {
$vuetify.lang.current = app.i18n.locale
app.i18n.onLanguageSwitched = (oldLocale, newLocale) => {
$vuetify.lang.current = newLocale
}
// const messages = {}
// if (process.server) {
// if (res.locals) {
// store.commit('setLocale', res.locals.acceptedLocale)
// if (res.locals.user_locale) {
// store.commit('setUserLocale', res.locals.user_locale)
// }
// }
// }
// messages[store.state.locale] = await import(/* webpackChunkName: "lang-[request]" */`../locales/${store.state.locale}.json`)
// always include en fallback locale
// if (store.state.locale !== 'en') {
// messages.en = await import('../locales/en.json')
// }
// if (store.state.user_locale) {
// merge(messages[store.state.locale], store.state.user_locale)
// }
// Set i18n instance on app
// app.i18n = new VueI18n({
// locale: store.state.locale,
// fallbackLocale: 'en',
// messages
// })
}
}