Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic translation keys from json are not extracted #208

Open
k0pper opened this issue Aug 22, 2022 · 0 comments
Open

Dynamic translation keys from json are not extracted #208

k0pper opened this issue Aug 22, 2022 · 0 comments

Comments

@k0pper
Copy link

k0pper commented Aug 22, 2022

I am building a gatsby website that holds some data in data/technologies.json:

[
   {
      "shortName": "Frontend",
      "longName": "Frontend Development",
      "descriptionPath": "leistungen.techstack.frontend"
   }
]

In the render method, I have code that is fetching this data with graphQL and sets the current selected element.

// get data
const techStacks = useStaticQuery...

// get current selected element
const techStack = techStacks[currentIndex]

Now, I want to use this descriptionPath field to insert as a translation key:

<FormattedMessage
	id=techStack.descriptionPath
	defaultMessage="This message should be extracted"
></FormattedMessage>

But when I run formatJS to extract these defaultMessages into a language file, an arbitrary key gets generated...

formatjs extract 'src/**/*.tsx' --out-file src/intl/de.json --format simple 
// should be "leistungen.techstack.frontend": "This message should be extracted"
"rnIXQm": "This message should be extracted"

Why is that? I can't be the only one with this problem. I feel like iterating over an array with data that should be dynamically translated is very common. Really hope someone can assist me with that.

Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant