ttag-org / ttag

:orange_book: simple approach for javascript localization
https://ttag.js.org/
MIT License
345 stars 43 forks source link

No translation when identifier resolves to undefined #183

Closed glecetre closed 5 years ago

glecetre commented 5 years ago

Hello,

We are using ttag on one of our projects and we recently faced an issue with it. We have a translation key containing a simple identifier. It is correctly translated when the identifier is set, but not when it is undefined.

I reproduced the situation in this codesandbox. You can comment or uncomment line 10 of index.js to see that the translation is OK when commented out, but not when uncommented. "coucou" is the original text and "hi" is the translation.

AlexMost commented 5 years ago

Hi @glecetre! Looked through your example and noticed that you are using string type for msgstr, but it must be a string[]. msgstr must be an array of strings. But seems like you have found a bug with undefined. Will take a look closer today. Thanks for the report!

glecetre commented 5 years ago

I fixed the snippet following your explaination :) Thanks for looking into it

AlexMost commented 5 years ago

The new version with fix is available - 1.7.18. Seems like it works https://codesandbox.io/s/beautiful-bird-2vj37. Thanks for the report, let me know if something doesn't work for you!