ttag-org / ttag

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

gettext("") returns headers when using ttag-cli's po2json with default arguments #196

Open AllenPasch opened 4 years ago

AllenPasch commented 4 years ago

When using the default arguments for ttag-cli's po2json command, the headers are placed as an object inside the translation of the empty string. Then, when you call gettext() with an empty value, the headers are shown in the UI.

The typing information for gettext() says it returns a string, which isn't true in this case. And the documentation doesn't hint to this very surprising behavior.

I think the correct change would be to strip header objects inside gettext() and similar functions, in case someone uses ttag-cli's po2json command with the default arguments. It would also be possible change ttag-cli's po2json command to use --force compact by default, but that could break existing consumers.

AlexMost commented 4 years ago

Hi @AllenPasch! Thanks for the report. 100% agree that we should not replace an empty string with headers, will try to fix that ASAP. compact will be enabled by default in the next minor version, going to release that soon also.