fix: improve i18n tStr() (#4966)

This commit is contained in:
jack zhang 2024-07-30 11:24:00 +08:00 committed by GitHub
parent 80182dc156
commit 9adfd4cbab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,9 +4,9 @@ import { useApp } from '@nocobase/client';
export function useT() {
const app = useApp();
return (str: string) => app.i18n.t(str, { ns: pkg.name });
return (str: string) => app.i18n.t(str, { ns: [pkg.name, 'client'] });
}
export function tStr(key: string) {
return `{{t('${key}', { ns: '${pkg.name}', nsMode: 'fallback' })}}`;
return `{{t(${JSON.stringify(key)}, { ns: ['${pkg.name}', 'client'], nsMode: 'fallback' })}}`;
}