From 9adfd4cbab188e471bd2754b752126a2149b37aa Mon Sep 17 00:00:00 2001 From: jack zhang <1098626505@qq.com> Date: Tue, 30 Jul 2024 11:24:00 +0800 Subject: [PATCH] fix: improve i18n `tStr()` (#4966) --- packages/core/cli/templates/plugin/src/client/locale.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/cli/templates/plugin/src/client/locale.ts b/packages/core/cli/templates/plugin/src/client/locale.ts index acaee6a43d..8d6dc7b9f6 100644 --- a/packages/core/cli/templates/plugin/src/client/locale.ts +++ b/packages/core/cli/templates/plugin/src/client/locale.ts @@ -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' })}}`; }