You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置i18next-parser使translation.json值与键一致

解决i18next-parser生成键值一致的translation.json问题

要让生成的translation.json中值与键完全相同,只需修改配置文件里的defaultValue选项,将其设置为一个返回当前key的函数即可:

修改你的i18next-parser.config.ts配置:

export default {
  contextSeparator: '::',
  // 将defaultValue设为函数,返回key本身作为默认值
  defaultValue: (lng: string, ns: string, key: string) => key,
  // 保留其他默认配置项...
};

配置完成后,解析tsx代码生成的translation.json就会符合需求:

{
  "Hello world header!": "Hello world header!"
}

内容的提问来源于stack exchange,提问作者Leila Nikonova

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 09:00:56