woboq / tr

Translation tools for rust
57 stars 9 forks source link

option for xtr to only update line numbers if one of the messages has changed #6

Closed kellpossible closed 4 years ago

kellpossible commented 4 years ago

It would nice to have an option to use xtr in a mode where the line numbers are only updated if one of the messages changes, that way the pot file could be checked into source control and xtr could be executed during a build script and feedback on changes to strings which affect translations can be immediate.

At the moment this isn't really possible because line numbers cause the checked-in file to be updated upon almost every change to code, even when it has nothing to do with messages.

ogoffart commented 4 years ago

The purpose of the line number is to help the translator to see the original source code with the string. So if they are wrong, this is not helping. Then maybe it is better not to have the line number at all. (We could imagine an option for that)

What you are asking is difficult, because we do not know the "previous" state when generating.

So if anything, it should just be an option to leave the line numbers out.

ogoffart commented 4 years ago

xgettext has a --no-location option that remove the location. Maybe that can be implemented.

ogoffart commented 4 years ago

Or better: --add-location=file. Which do not add the line numbers

kellpossible commented 4 years ago

The purpose of the line number is to help the translator to see the original source code with the string. So if they are wrong, this is not helping.

But during development, if the pot file is checked into source code, I would argue that it will not be up to date with the line numbers anyway because most people are not going to run xtr and update translations on every commit if they know that the change has nothing to do with changing strings, and possibly they may even delay updating the pot files until release.

xgettext has a --no-location option that remove the location. Maybe that can be implemented.

Or better: --add-location=file. Which do not add the line numbers

It seems like some of those ideas could also perhaps work as solutions to this problem. I like the --add-location=file idea, seeing as at least in the way I can imagine using the tool (and how I've seen similar tools used in the past during production), the line numbers would be out of date fairly often anyway.

kellpossible commented 4 years ago

I'm happy to have a try at implementing those --no-location and --add-location options tomorrow if you'd like :)

ogoffart commented 4 years ago

Thanks. Please have a look at the xgettext man page and try to keep the same command syntax: https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html

ogoffart commented 4 years ago

Closing this issue since i believe that #7 will fit your need.