我正在使用Typescript构建Next.JS应用程序,希望在页面/组件之外访问next-i18next翻译,以便本地化验证消息,而所有验证引擎都定义在单独的实用程序类中。我检查了next-i18next是否有任何类型的静态访问器,但没有成功。有什么建议吗?
发布于 2021-03-08 22:20:38
我认为唯一的方法是将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);https://stackoverflow.com/questions/66527036
复制相似问题