jy95 / i18n-tools

🧰CLI to make common operations around i18n files simpler.
https://jy95.github.io/i18n-tools/
GNU General Public License v3.0
37 stars 5 forks source link

Got a error if `columns.locale` is `zh-CN` #61

Closed zqjimlove closed 2 years ago

zqjimlove commented 2 years ago

At least a duplicated value in files JSON object was detected

{"columns":[{"locale":"en","label":"en"},{"locale":"zh-CN","label":"zh-CN"}],"files":{"en":"/translations/en/translation.json","zh-CN":"/translations/zh-CN/translation.json"},"filename":"translation","outputDir":"/Users/hujin/Projects/socialFi/alienswap-app/temp"}
jy95 commented 2 years ago

Hello,

Thanks for the report - it seems thrown by this line :

  if (uniq(Object.values(files)).length !== entries.length) {
    return new Error(
      `At least a duplicated value in files JSON object was detected`
    );
  }

Obviously, some stuff happened that made that condition true whereas it shouldn't When I tried to reproduced it, I saw that yargs duplicated your "zh-CN" entry :

{
  EN: 'D:\\TEMP\\TEMP\\tests-for-export-xlsx\\correct\\fr.json',
  'zh-CN': 'D:\\TEMP\\TEMP\\tests-for-export-xlsx\\correct\\de.json',
  zhCN: 'D:\\TEMP\\TEMP\\tests-for-export-xlsx\\correct\\de.json'
}

Apparently, by default, yargs has a setting in his inner parser called camel-case expansion set to true that caused that issue. @zqjimlove I created a fix : can you check if your issue is solved with v1.6.7 please ? (Reopen the issue if it isn't the case)