ttag-org / ttag

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

Comment printed more than once #149

Closed mkosir closed 4 years ago

mkosir commented 5 years ago

Not really a critical bug, but I noticed that I get comment printed more than once in some cases.
I assume this happens when the msgid is found in the codebase more than once:

#: src\components\FIS\index.js:281
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
#: src\components\FIS\index.js:288
msgid "Error fetching data"
msgstr ""
AlexMost commented 5 years ago

Can you please provide a little example that will help to reproduce this case?

mkosir commented 5 years ago

I created a small repo to reproduce - https://github.com/markokosir/react-ttag-comments and ran npx ttag update i18n/en.po src/

AlexMost commented 5 years ago

I have tried your example and seems like everything is ok for me:

#: src/App.js:12
#: src/App.js:23
msgid "Test string twice"
msgstr ""

Those comments are extracted to provide info about all msgid occurrences. If you don't want to extract those comments you can provide --extractLocation=never option.

npx ttag update --extractLocation=never i18n/en.po src/
mkosir commented 5 years ago

Thanks for suggestion with CLI option flag --extractLocation=never, it will come in handy before sending files for translation.
However if it helps, I tested same application also on Ubuntu and comments are printed as they should be, so the issue is only present on Win10 system. On both systems npx version is the same 6.7.0 As far as I am concerned issue can be closed.