mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-24 16:56:14 -04:00
21 lines
517 B
TypeScript
21 lines
517 B
TypeScript
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;
|
|
};
|