{ “内容”:{ “ zh”:{ “ transfer_screen_amount_title”:“金额”, “ demo_screen_welcome_title”:“欢迎” }, “ bm”:{ “ transfer_screen_amount_title”:“朱姆拉”, “ demo_screen_welcome_title”:“ Selamat大唐” } } }
我认为为了检索该值,我们可以将其设置为 t('content.en.transfer_screen_amount_title')。 如果我想像这样使用它而不是 t('transfer_screen_amount_title') ??
怎么办?答案 0 :(得分:0)
这取决于翻译的加载方式:https://www.i18next.com/how-to/add-or-load-translations
下面是在init上加载资源的示例: https://github.com/i18next/react-i18next/blob/master/example/react-native/App.js#L20 因此您的代码将如下所示:
i18next
.use(languageDetector)
.use(initReactI18next)
.init({
fallbackLng: 'en',
debug: true,
defaultNS: 'content',
resources: {
en: {
content: {
transfer_screen_amount_title: 'Amount',
demo_screen_welcome_title: 'Welcome',
},
},
bm: {
content: {
transfer_screen_amount_title: 'Jumlah',
demo_screen_welcome_title: 'Selamat Datang',
},
},
},
});
// t('transfer_screen_amount_title')