mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-16 16:04:34 +00:00
24 lines
513 B
TypeScript
24 lines
513 B
TypeScript
import { useTranslation as useNextTranslation } from 'next-i18next';
|
|
import { I18N_NAMESPACES_MAP } from '../i18n/constants';
|
|
|
|
export function useTranslation() {
|
|
const { t: originalT, ...rest } = useNextTranslation();
|
|
|
|
const t = (key: string | undefined, ...args: any[]): string => {
|
|
if (!key) return '';
|
|
|
|
const ns = key.split(':')[0];
|
|
if (!I18N_NAMESPACES_MAP[ns as any]) {
|
|
return key;
|
|
}
|
|
|
|
// @ts-ignore
|
|
return originalT(key, ...args);
|
|
};
|
|
|
|
return {
|
|
t,
|
|
...rest
|
|
};
|
|
}
|