Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove line numbers from pot and po files? #289

Open
mauritsvanrees opened this issue Mar 17, 2020 · 5 comments
Open

Remove line numbers from pot and po files? #289

mauritsvanrees opened this issue Mar 17, 2020 · 5 comments
Assignees

Comments

@mauritsvanrees
Copy link
Member

Do we still want the line numbers in the comments? So for example this:

#: CMFPlone/interfaces/controlpanel.py:1499

The line numbers often change, and this gives long diffs, like in this PR. The PR is about updated translations for plone.app.discussion, which is a big diff, but the biggest part of the diff is updated line numbers in totally different places.

I thought this was an option in i18ndude, but apparently not. I don't know how hard it would be. This is one of the lines that adds the line number.

Default would be the current behaviour, but for plone.app.locales we could change the command that we call.

Would that be useful? Or should we not bother?

@ale-rt
Copy link
Member

ale-rt commented Mar 17, 2020

And it would be also great to sort the message ids like

msgcat --no-location --no-wrap --sort-output file.po

can do.

TL;DR

Diffing po files annoyed me a lot in the past.

The solution I am adopting is to add the following lines in ~/.gitconfig:

[diff "msgcat"]
    textconv = msgcat --no-location --no-wrap --sort-output

and those lines in the project .git/attributes

*.po    diff=msgcat

This produces an output like:

[ale@emily plone.app.locales]$ git log -p ...
--- a/plone/app/locales/locales/it/LC_MESSAGES/widgets.po
+++ b/plone/app/locales/locales/it/LC_MESSAGES/widgets.po
@@ -285,6 +285,12 @@ msgstr "Esporta variabili per shim requirejs"
 msgid "Expression"
 msgstr "Espressione"
 
+msgid "External"
+msgstr ""
+
+msgid "External Image"
+msgstr ""

that sorts the lines and strips the comments.

It was inspired by: http://stackoverflow.com/questions/2006351/gettext-po-files-under-version-control/11291001#11291001

Unluckily this requires the developer some manual configuration (if you do not have msgcat installed it will break).

The advantage of this configuration is that I can really diff and review po files, without being discouraged by the amount of noise we usually see in the PRs.

If i18ndude could:

  • sort the messages
  • remove the noise
    I am all in.

@vincentfretin
Copy link
Member

Yes, I'm in favor of an i18ndude option to remove the line number in the comment. 👍

@mauritsvanrees
Copy link
Member Author

I have opened an issue for not adding line numbers. I don't know when I will get to that.

@ale-rt I think the messages are sorted already. In plone.app.locales master, when I ignore the comments in nl/plone.po:

$ cat plone.po | grep -v '^#' > orig
$ msgcat --no-wrap --sort-output orig > x
$ diff orig x
18a19,21
> msgid "\"${title}\" has already been deleted"
> msgstr "\"${title}\" is al verwijderd"
> 
5335,5337d5337
< msgid "\"${title}\" has already been deleted"
< msgstr "\"${title}\" is al verwijderd"
< 

So only one msgid/msgstr is sorted differently, and that is because it is a strange one.
Maybe it matters with which Python version i18ndude rebuild-pot was run. I don't know.

@lelit
Copy link
Contributor

lelit commented Oct 4, 2020

IMHO line numbers are useful: being a long time translator of several different packages, being able to quickly go to the source of the message is a definitely a plus, to better understand the context.

@mauritsvanrees
Copy link
Member Author

I have released i18ndude 5.5.0 with new option --no-line-numbers. Coredev 5.2 and 6.0 have this version available now. So we could update the scripts to use it.

The default is still to add the line numbers. This might change in the future. For people who want to keep the line numbers, I have added option --line-numbers. If you add this to your rebuild-pot command, you will keep the numbers also in future versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants