i added an option that make pygettext consider certain multi-line strings as single-line strings. If you're using an editor like kbabel, it's nice, you don't see the newlines. This comes really handy for strings to be used as HTML, where line breaks don't matter (and I'm sure for many other uses). You can select which keywords trigger this special extraction. All the other gettext tools work normally. Default behaviour does not change. I use it something like this: POTCMD = pygettext.py \ --verbose --extract-all --no-default-keywords \ --keyword-single=_ --keyword-single=N_ \ --keyword=__ ... pot: (POTCMD)−d(POTCMD) -d (POTCMD)−d(PROJECT) -p (dir(dir (dir@) $(PYFILES) cheers,
Logged In: NO Code review.... 1. You have a few lines like : s = '%s' % ' '.join(newlines) Surely that is the same as just: s = ' '.join(newlines) 2. You use the single line option value as part of the key in __messages dictionary. That means that the output will have duplicate msgid values if your source contains both _normal('hello world') and _single('hello world'). Other GNU gettext tools assume that there will not be duplicates. (assuming --keyword=_normal --keyword-single=_single) 3. You also get duplicates for: _single("""this is one line and this is another""") and _single("""this is one line and this is another""") because normalization is performed just before output. Unless Im missing something, I think the right solution to these two problems is to normalize before calling __addentry, and leave the key to __messages as it was originally.
A rare example of a 5-year old patch that still applies with only a minor tweak. This is probably a sign that pygettext itself has not been kept up to date. In any case, I am attaching an updated patch which I did not test beyond running pygettext.py -h. There was no response from OP to the patch review and from a brief look at the patch, it is not commit ready. I am adding this as a dependency to meta-issue #7962 so that the fate of this patch and pygettext itself can be decided.
I've applied a patch from #8502 that doesn't encourage the use of pygettext.py so strongly. I raised the issue of deprecating pygettext.py on python-dev on Nov 11 2013; the thread starts at <https://mail.python.org/pipermail/python-dev/2013-November/130123.html>. Barry Warsaw and Philip Jenvey suggested deprecating it; Martin von Loewis was OK with continuing to maintain pygettext. So I'll leave this issue open, in case anyone wants to review the patch and commit it.