【问题标题】:Can you use a redux store as the translation resources in next-i18next?可以在 next-i18next 中使用 redux store 作为翻译资源吗?
【发布时间】:2021-11-09 22:16:08
【问题描述】:

我有一个使用 contentEditable 文本设置的网站,这是用户可以编辑的文本内容,我需要设置翻译,以便当用户编辑此文本时,它会在 translations.json 文件中更新。我设置了一个 redux 存储,其中存储的操作与传递给资源的 translations.json 文件的外观完全相同。问题是我真的不知道如何让 next-i18n 使用这个 store 作为翻译资源。

next-i18n 文档说我应该在配置中设置翻译:

export async function getServerSideProps({locale}) {
  return {
    props: {
      ...await serverSideTranslations(locale, ['common', 'slide1'], config
      ),
    }
  }
}

配置可以包含资源,但我不能在 getServerSideProps 中使用 redux 选择器。

【问题讨论】:

    标签: reactjs next.js i18next react-i18next next-i18next


    【解决方案1】:

    使用 react-i18n 和 i18n.addResource 函数代替 redux。您不能删除资源,因此现有文本的键不能是动态的。但这对我来说没关系

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-14
      • 2020-06-07
      • 2020-04-25
      • 2021-09-18
      • 1970-01-01
      • 2021-06-06
      • 2023-03-21
      • 2021-04-11
      相关资源
      最近更新 更多