bugGNU gettext - Bugs: bug #42376, xgettext: comment for...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #42376: xgettext: comment for language=Python may be omitted if first argument starts not at a line with keyword

Submitter:  nott <nott_>
Submitted:  Fri 16 May 2014 12:24:16 PM UTC
   
 
Category:  Programmer tools Severity:  3 - Normal
Item Group:  None Status:  Duplicate
Privacy:  Public Assigned to:  ueno
Open/Closed:  Closed

Jump to the original submission

Wed 03 May 2023 04:36:04 PM UTC, comment #9: 
Bruno Haible <haible>
Group administrator
Mon 01 Dec 2014 07:48:02 AM UTC, comment #8: 
Daiki Ueno <ueno>
Group administrator
Wed 21 May 2014 04:47:03 PM UTC, comment #7: 

Indeed, you're right, I'm sorry, it worked when placing the comment above the string when I retried it.
I don't know what went wrong with my first try.

Maybe we should document to put it just above the string and not before the gettext call.

Thanks for your help.

Yves-Gwenael Bourhis <ygbo>
Wed 21 May 2014 09:15:08 AM UTC, comment #6: 

That's strange.  I got the output below if I run xgettext as follows:


xgettext -o - --omit-header --add-comments=Translators --keyword=ungettext_lazy:1,2 test.py



#. Translators: This doesn't work either
#: test.py:3
msgid "singular example 1"
msgid_plural "plural example 1"
msgstr[0] ""
msgstr[1] ""


Daiki Ueno <ueno>
Group administrator
Wed 21 May 2014 08:49:14 AM UTC, comment #5: 

Hi,

I have tried doing so as mentionned here: https://code.djangoproject.com/ticket/22578#ticket :

ungettext_lazy(
    # Translators: This doesn't work either
    "singular example 1",
    "plural example 1",
    count
)

with https://github.com/django/django/blob/master/django/core/management/commands/makemessages.py line 107:

'--keyword=ungettext_lazy:1,2'


But it doesn't seem to work.

Thanks for your help.

Yves-Gwenael Bourhis <ygbo>
Tue 20 May 2014 10:50:44 PM UTC, comment #4: 

Well, I meant to put comments inside the argument list, like this:


some_message = ungettext(
    # Translators: Hope this helps you.
    "This is the singular sentence, it is "
    "long and needs to be split on several"
    "lines.",
    "This is the plural sentence, it is "
    "long and needs to be split on several"
    "lines.",
    0
    )


PEP8 doesn't seem to forbid this and actually flake8 accepts it.

Daiki Ueno <ueno>
Group administrator
Tue 20 May 2014 12:13:00 PM UTC, comment #3: 

We can't always easily workaround this by putting the comment immediately followed by the first argument, because by doing so the code could fail being validated by PEP8:
http://legacy.python.org/dev/peps/pep-0008/#indentation
http://legacy.python.org/dev/peps/pep-0008/#maximum-line-length

example:

class Foo(Object):
    def method(self):
        if condition 1:
            if condition 2:
                for i in xrange(10):
                    # Translators: Hope this helps you.
                    some_message = ungettext(
                        "This is the singular sentence, it is "
                        "long and needs to be split on several"
                        "lines.",
                        "This is the plural sentence, it is "
                        "long and needs to be split on several"
                        "lines.",
                        i
                    )
                    do_something_with(some_message)


"Aligned with opening delimiter" indentation would make it harder by needing to split the text even more into very short lines each

We often need this kind of indentation otherwise code gets rejected by pep8 and flake8 code styling validators.

Strings formatted this way (implicit multi-line joined strings) is very common in python code in order to respect it's indentation requirements.

Yves-Gwenael Bourhis <ygbo>
Sat 17 May 2014 01:22:17 AM UTC, comment #2: 

https://savannah.gnu.org/bugs/?33451

It is known but I wonder if it is worth being supported, though we probably should clarify the current behavior in the documentation.

Can't you easily work this around by putting the comment immediately followed by the first argument?

Daiki Ueno <ueno>
Group administrator
Fri 16 May 2014 12:30:00 PM UTC, comment #1: 

$ xgettext --version
xgettext (GNU gettext-tools) 0.18.3
Copyright (C) 1995-1998, 2000-2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Ulrich Drepper.

nott <nott_>
Fri 16 May 2014 12:24:16 PM UTC, original submission:  

xgettext: comment for language=Python may be omitted if first argument starts not at a line with keyword

Consider we have a file like that:

# Translators: This does not work
ungettext(
    "singular example 1",
    "plural example 1",
    count
)

# Translators: This works
ungettext("singular example 2", "plural example 2", count)

# Translators: This works too
ungettext("singular example 3",
               "plural example 3",
               count)




$ xgettext --language=Python  --keyword=ungettext:1,2 --output=- --add-comments=Translators xgettext_bug.py
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-05-16 15:07+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#: t22578/urls.py:3
msgid "singular example 1"
msgid_plural "plural example 1"
msgstr[0] ""
msgstr[1] ""

#. Translators: This works
#: t22578/urls.py:9
msgid "singular example 2"
msgid_plural "plural example 2"
msgstr[0] ""
msgstr[1] ""

#. Translators: This works too
#: t22578/urls.py:12
msgid "singular example 3"
msgid_plural "plural example 3"
msgstr[0] ""
msgstr[1] ""


The bug was initially found in Django: https://code.djangoproject.com/ticket/22578#no4

nott <nott_>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Updated the item)
  • -email is unavailable- added by ygbo (Posted a comment)
  • -email is unavailable- added by ueno (Posted a comment)
  • -email is unavailable- added by nott_ (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-27 haible CategoryNone Programmer tools
        Assigned toNone ueno
    2014-12-01 ueno Open/ClosedOpen Closed
    2014-05-17 ueno StatusNone Duplicate

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code