- Closes #9
- Removed dependency on vue-i18n
- Localization Changes
This commit is contained in:
Shiny Nematoda 2022-09-12 15:00:54 +00:00
parent 44db54737b
commit fcc3d455c6
No known key found for this signature in database
GPG key ID: 6506D50F5613A42D
18 changed files with 143 additions and 270 deletions

View file

@ -1,29 +0,0 @@
import { useI18n } from 'vue-i18n';
export const SUPPORTED_LOCALES = [
{
code: 'en',
name: 'English',
},
];
export function useT(path) {
const { messages, locale, fallbackLocale } = useI18n(),
msgs = messages.value?.[locale.value],
fallback = messages.value?.[fallbackLocale.value],
keys = path.split('.'),
translate = msg => keys.reduce((obj, i) => obj?.[i], msg),
translated = translate(msgs) || translate(fallback);
return translated || path;
}
export function useSetupLocale(locale) {
import(`@/locales/${locale}.json`)
.then(mod => mod.default)
.then(mod => {
window.i18n.global.messages.value[locale] = mod;
});
window.i18n.global.locale.value = locale;
}