mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-11-29 18:58:26 +08:00
fix: i18n plugin utils (#4962)
This commit is contained in:
parent
e727581967
commit
646f3a8d04
@ -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' })}}`;
|
||||
}
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user