我在 React Native 应用程序中使用 i18next 和 react-i18next ,更具体地说是输入验证。我试图将 t() 作为 no 组件中的参数传递,但收到错误“TypeError: n 不是函数。(在 'n('errorMessages.emailNoMatch')' 中,'n' 未定义) ”。非常感谢任何建议,因为我对编码相对较新,并且我已经为此问题搜索了几天。
这是 i18n.js 代码:
import i18next from 'i18next';
import common_de from './translations/de/common.json';
import common_en from './translations/en/common.json';
import i18n from 'i18n-js';
import * as Localization from 'expo-localization';
// Set up translations
i18next.init({
interpolation: { escapeValue: false }, // React already does escaping
lng: 'en', // language to use
resources: {
de: {
common: common_de, // 'common' is our custom namespace
},
en: {
common: …Run Code Online (Sandbox Code Playgroud)