Plural values are deleted by i18next-scanner

1k Views Asked by At

Recently I came across a strange behavior, I am not sure whether is my fault or a bug ... (probably my fault though) I have the following Trans Component:

<Trans i18nKey="projectDetailList.pledgesInfo" count={promotions.length}>
    <p>
        Explore <span>{{promotionLength: promotions.length}} pledge</span>
    </p>
</Trans>

in my locale translation.json files its keys (singular and plural) are declared as follows both for english and italian language:

locales/en/translation.json
...
"projectDetailList": {
    "noPromotionsFound": "No promotions found for this project! Try again later!",
    "pledgesInfo": "<0>Explore <1>{{count}} pledge</1></0>",
    "pledgesInfo_plural": "<0>Explore all <1>{{count}} pledges</1></0>"
}
...
locales/it/translation.json
...
"projectDetailList": {
    "noPromotionsFound": "Nessuna promozione trovata per questo progetto! Prova più tardi!",
    "pledgesInfo": "<0>Esplora <1>{{count}} pledge</1></0>",
    "pledgesInfo_plural": "<0>Esplora tutti i <1>{{count}} pledges</1></0>"
}
...

It works like a charm, and correctly translate, select the appropriate key for plural and interpolate variables, however anytime I launch i18next-scanner both the keys pledgesInfo_plural are removed from both the locale files... what am I doing wrong? As anyone experienced this issue?

That's my i18next-scanner.config.js file:

module.exports = {
  options: {
    debug: false,
    sort: true,
    removeUnusedKeys: true,
    func: {
      list: ["t"],
      extensions: [".js"]
    },
    trans: {
      component: "Trans",
      i18nKey: "i18nKey",
      defaultsKey: "defaults",
      extensions: [".js"],
      fallbackKey: function(ns, value) {
        // Returns a hash value as the fallback key
        return sha1(value);
      }
    },
    lngs: ["en", "it"],
    ns: ["translation"],
    defaultLng: "en",
    defaultNs: "translation",
    defaultValue: "",
    resource: {
      loadPath: "translations/locales/{{lng}}/{{ns}}.json",
      savePath: "translations/locales/{{lng}}/{{ns}}.json",
      jsonIndent: 2,
      lineEnding: "\n"
    },
    nsSeparator: ":", // namespace separator
    keySeparator: ".", // key separator
    interpolation: {
      prefix: "{{",
      suffix: "}}"
    }
  }
};

Thanks for your patience!

0

There are 0 best solutions below