i18next-parser icon indicating copy to clipboard operation
i18next-parser copied to clipboard

Can't parse namespace from getFixedT usage

Open pybuche opened this issue 1 year ago • 5 comments

🐛 Bug Report

Looking at the documentation and different issues I found, especially this one (https://github.com/i18next/i18next-parser/issues/703#issuecomment-1327896105), it seems that using i18n.getFixedT should help specify a single namespace for a whole file.

To Reproduce

I managed to craft a minimal reproduction repo here

Expected behavior

What I'm looking for behind this feature of getFixedT is to be able to specify a t function for a whole file, without repeating the namespace name at each function usage.

For instance, with a file defining lots of metadata for my app:

const t = i18n.getFixedT(null, "myFileNameSpace")

const DATA = [
   {
      name: t("item1.name"),
      description: t("item2.description"),
   },
   {
      name: t("item2.name"),
      description: t("item2.description"),
   },
]

I'd like the parser to extract a myFileNameSpace.json containing the keys specified. Instead, the keys are extracted in the default namespace.

Your Environment

  • runtime version: i.e. node v18, browser Chrome, latest version
  • i18next version: 23.10.1
  • i18next-parser version: 8.13.0
  • os: Mac

pybuche avatar Mar 13 '24 17:03 pybuche

I'm having the same issue. It would be nice if we can get some info about this.

GeorgEduard avatar Oct 14 '24 13:10 GeorgEduard

I'm also experiencing the same issue.

DavideTriso avatar Nov 25 '24 07:11 DavideTriso

same here :(

thomasmery avatar Feb 11 '25 10:02 thomasmery

Hitting this issue as well, which forces me to specify the namespace for each translated string:

i18n.t("item1.name", {
    ns: "myFileNameSpace",
    defaultValue: "Default value",
})

nicmeriano avatar Mar 05 '25 18:03 nicmeriano

You may want to try with https://github.com/i18next/i18next-cli

adrai avatar Sep 30 '25 11:09 adrai