我正在尝试使用 typescript 4.1.2 在我的 React Native 应用程序中配置react-i18next 11.8.2:
i18n.use(initReactI18next).init({
resources: {
en,
es,
},
lng: 'es',
fallbackLng: 'es',
interpolation: {
escapeValue: false,
},
});
Run Code Online (Sandbox Code Playgroud)
有两个资源文件(en,es)。
但我在使用 useTranslation 挂钩的 TFunction 接口中遇到打字稿错误:
const {t, i18n} = useTranslation(['SelectLanguage']);]
<StyledLabel>{t('SelectLanguage:title')}</StyledLabel>
Run Code Online (Sandbox Code Playgroud)
错误:
No overload matches this call.
Overload 1 of 2, '(props: Pick<Pick<TextProps & RefAttributes<Text>, "key" | "ref" | "style" | "onLayout" | "testID" | "nativeID" | "accessible" | "accessibilityActions" | ... 35 more ... | "dataDetectorType"> & Partial<...>, "key" | ... 42 more ... …Run Code Online (Sandbox Code Playgroud) internationalization typescript react-native react-i18next react-native-ui-kitten