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

Keep po files line length at 80 characters #3

Closed
gforcada opened this Issue Feb 26, 2013 · 5 comments

Comments

Projects
None yet
2 participants
@gforcada
Copy link
Contributor

gforcada commented Feb 26, 2013

Its quite annoying that all translation editors do that, wrap translations strings at 80 characters, but then when you update the po files with i18ndude they are unwrapped and kept as huge lines.

More over, it makes it difficult to grasp the changes if you have translations in a version control system, as lots of strings show up in the diff.

@mauritsvanrees

This comment has been minimized.

Copy link
Member

mauritsvanrees commented Mar 2, 2013

My Emacs editor does not do that. ;-)

But this should be fixable in the POWriter class in catalog.py. Can you paste an example of how a file looks after a translation editor has wrapped the lines?

@gforcada

This comment has been minimized.

Copy link
Contributor Author

gforcada commented Mar 2, 2013

See below how it should look like:

Short lines (the second one) should be kept within a single line. For longer lines, the line with the msgstr is kept empty and all the text goes below (string 1).

The same goes for the msgid (as seen also on string 1).

For location lines (the ones starting with #: they can be on the same line while being within 80 characters, or be on other lines if they do not fit on 80 characters.

#: ../data/org.gnome.shell.gschema.xml.in.in.h:2
msgid ""
"Allows access to internal debugging and monitoring tools using the Alt-F2 "
"dialog."
msgstr ""
"Geeft toegang tot interne debugging- en observatieprogramma's met behulp van "
"het Alt-F2-dialoogvenster."

#: ../data/org.gnome.shell.gschema.xml.in.in.h:3
msgid "Uuids of extensions to enable"
msgstr "Uuid's van in te schakelen uitbreidingen"

mauritsvanrees added a commit that referenced this issue Sep 7, 2013

@mauritsvanrees

This comment has been minimized.

Copy link
Member

mauritsvanrees commented Sep 7, 2013

Okay, I have fixed this.

When writing files the script wraps msgid and msgstr lines at 79 characters, as most PO editors do that. You can set an environment variable PO_MAX_WIDTH to choose a different length. If this is two or less, we do no wrapping, because all lines must be enclosed in quotes.

A command line option would have been nicer, but the way the script current reads command line arguments makes that hard, needing a lot of changes. Rewriting the script to use argparse would be a better first step.

BTW, the msgattrib command line tool from GNU gettext can do wrapping or unwrapping.

@mauritsvanrees

This comment has been minimized.

Copy link
Member

mauritsvanrees commented Oct 13, 2013

I have changed this. i18ndude does not look for a PO_MAX_WIDTH environment variable anymore. It has a command line option --wrap to wrap long lines, and --width=NUM to change the default line width of 79. The default is still to not wrap.

I have released 3.3.0 with this change.

@gforcada

This comment has been minimized.

Copy link
Contributor Author

gforcada commented Oct 13, 2013

Awesome!

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.