0

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

这就是 next-i18n 文档说我应该在配置中设置翻译的方式:

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

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

4

1 回答 1

0

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

于 2021-09-15T10:06:12.080 回答