我正在使用 Typescript 构建 Next.JS 应用程序,并希望访问页面/组件之外的 next-i18next 翻译,以便本地化验证消息,而所有验证引擎都在单独的实用程序类中定义。已经检查了 next-i18next 是否有任何类型的静态访问器,但那里没有运气。有什么建议么?
问问题
374 次
1 回答
1
我认为唯一的方法是将i18n
作为参数传递给您的实用程序类。
import { withTranslation, WithTranslation } from 'i18n';
import { checkFunction } from '../utils';
type Props = WithTranslation;
const Page: React.FC<Props> = (props) => {
const result = checkFunction(props.i18n);
}
export default withTranslation(['common'])(Page);
于 2021-03-08T14:20:38.163 回答