mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-24 23:00:19 +03:00
* feat: add script to extract strings * feat: extract many strings (html, attr, label) * feat(extract string): extract html only for .vue and single file mode * fix: __i18n_ally_root__ * feat: nestify en.yml + extract tab attributes * feat: add script to extract strings * feat: extract many strings (html, attr, label) * feat(extract string): extract html only for .vue and single file mode * fix: __i18n_ally_root__ * feat: nestify en.yml + extract tab attributes * fix: lint * feat: add vue-i18n-extract to check missing keys * fix: unit tests * fix: update vue i18n plugin
22 lines
578 B
TypeScript
22 lines
578 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: import.meta.env.VITE_LANGUAGE || 'en',
|
|
messages,
|
|
});
|
|
|
|
export const i18nPlugin: Plugin = {
|
|
install: (app) => {
|
|
app.use(i18n);
|
|
},
|
|
};
|
|
|
|
export const translate = function (localeKey: string, list: unknown[] = []) {
|
|
const hasKey = i18n.global.te(localeKey, get(i18n.global.locale));
|
|
return hasKey ? i18n.global.t(localeKey, list) : localeKey;
|
|
};
|