diff --git a/packages/core/cli/templates/plugin/src/client/locale.ts b/packages/core/cli/templates/plugin/src/client/locale.ts index 2cf2a95584..acaee6a43d 100644 --- a/packages/core/cli/templates/plugin/src/client/locale.ts +++ b/packages/core/cli/templates/plugin/src/client/locale.ts @@ -1,12 +1,12 @@ -import { useTranslation } from 'react-i18next'; - // @ts-ignore import pkg from './../../package.json'; +import { useApp } from '@nocobase/client'; -export function usePluginTranslation() { - return useTranslation([pkg.name, 'client'], { nsMode: 'fallback' }); +export function useT() { + const app = useApp(); + return (str: string) => app.i18n.t(str, { ns: pkg.name }); } -export function generatePluginTranslationTemplate(key: string) { - return `{{t('${key}', { ns: ['${pkg.name}', 'client'], nsMode: 'fallback' })}}`; +export function tStr(key: string) { + return `{{t('${key}', { ns: '${pkg.name}', nsMode: 'fallback' })}}`; } diff --git a/packages/core/client/src/i18n/i18n.ts b/packages/core/client/src/i18n/i18n.ts index b0618a2a00..98b7d59020 100644 --- a/packages/core/client/src/i18n/i18n.ts +++ b/packages/core/client/src/i18n/i18n.ts @@ -37,7 +37,7 @@ i18n lng: 'en-US', // debug: true, defaultNS: 'client', - // fallbackNS: 'client', + fallbackNS: 'client', // backend: { // // for all available options read the backend's repository readme file // loadPath: '/api/locales/{{lng}}/{{ns}}.json',