Fla
Fla

Reputation: 647

Translations in a typescript object are not working

I have a bug that I don't understand, I am using lingui for i18n of my app. I have translations done with the macro t in a typescript object: https://github.com/Flaburgan/disco2very/blob/master/data/ademe/footprintDetailCategories.ts#L8

They are correctly extracted: https://github.com/Flaburgan/disco2very/blob/master/locales/en/messages.po#L164

And correctly compiled, I find them with the good key in both my English and French ts file which result from the compilation.

The array is then used here: https://github.com/Flaburgan/disco2very/blob/master/components/explanation-dialog.tsx#L48

However, after deploying in production, translations are not displayed, the key is displayed instead, for both English and French:

enter image description here

Here is how I load i18n: https://github.com/Flaburgan/disco2very/blob/master/components/App.tsx#L28

What am I doing wrong? Is it that the array is not "aware" of the local to load? Thank you.

Upvotes: 0

Views: 87

Answers (1)

PatAttack
PatAttack

Reputation: 41

Some of your links are broken. You must have updated your master branch since your post. I recommend checking your code to a dedicated branch for asking questions and leaving them be until your question is resolved.

If you have a big object with translation needs, I recommend msg macro instead of t. The syntax is very similar. You then use i18n._(SOME_MESSAGE_DESCRIPTER) to access the localized strings.

Upvotes: 0

Related Questions