feat(i18n): support for i18n in .ts files (#683)

(cherry picked from commit 732313bfc32a514ef064ca0f90304ff05e2e7ef3)
This commit is contained in:
莫颓 2023-10-22 16:23:00 +08:00 committed by GitHub
parent 84a4a646f6
commit ebb4ec4165
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,3 +29,9 @@ export const i18nPlugin: Plugin = {
app.use(i18n); app.use(i18n);
}, },
}; };
export const translate = function (localeKey: string) {
// @ts-expect-error global
const hasKey = i18n.global.te(localeKey, i18n.global.locale);
return hasKey ? i18n.global.t(localeKey) : localeKey;
};