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

13
locales/loader.js Normal file
View File

@@ -0,0 +1,13 @@
export default async (context, locale) => {
try {
if (process.server) {
return context.$axios.$get(`locale/${locale}`)
} else {
return fetch(`${window.location.origin}/api/locale/${locale}`).then(ret => ret.json())
}
} catch (e) {
console.error(`Error loading locale ${locale}`, e)
}
return localeMessages
}