Files
it-tools/src/plugins/i18n.plugin.ts
T
sharevb a8c6ebc81b Feat/translate all content (#121)
* 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
2025-07-20 21:01:01 +02:00

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;
};