mirror of
https://codeberg.org/Hyperpipe/Hyperpipe
synced 2025-06-28 05:08:00 +02:00
Changes:
- Closes #9 - Removed dependency on vue-i18n - Localization Changes
This commit is contained in:
parent
44db54737b
commit
fcc3d455c6
18 changed files with 143 additions and 270 deletions
|
@ -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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue