a
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import messages from '@intlify/unplugin-vue-i18n/messages';
|
||||
import { get } from '@vueuse/core';
|
||||
import type { Plugin } from 'vue';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'en',
|
||||
messages,
|
||||
});
|
||||
|
||||
export const i18nPlugin: Plugin = {
|
||||
install: (app) => {
|
||||
app.use(i18n);
|
||||
},
|
||||
};
|
||||
|
||||
export const translate = function (localeKey: string) {
|
||||
const hasKey = i18n.global.te(localeKey, get(i18n.global.locale));
|
||||
return hasKey ? i18n.global.t(localeKey) : localeKey;
|
||||
};
|
||||
Reference in New Issue
Block a user