Skip to content

Conversation

@st4lk
Copy link

@st4lk st4lk commented Jan 26, 2015

xgettext allows to have different arguments for same keyword, whereas babel doesn't. This pull request fix it.

Example

some_file.py contents:

print _("Hello")
print _("Event", "Events", 5)
  • output of xgettext some_file.py --language=Python --output-dir=locale --keyword=_ --keyword=_:1,2:
#: some_file.py:1
msgid "Hello"
msgstr ""

#: some_file.py:2
msgid "Event"
msgid_plural "Events"
msgstr[0] ""
msgstr[1] ""
  • output of pybabel extract ./ --output=locale/messages.pot --keyword=_ --keyword=_:1,2
#: some_file.py:1
msgid "Hello"
msgstr ""

#: some_file.py:2
msgid "Event"
msgstr ""

As we can see, xgettext correctly found plural argument list for _("Event", "Events", 5). But babel treats function _ to have only one argument, ignoring option --keyword=_:1,2 and therefore assumes, that "Event" has no plural forms.

P.S.
In tornado web framework, function _ can take both the single string and a string with plural form and with count. I found it useful, as we don't need to have another translate function name for such case.

@sils
Copy link
Member

sils commented Aug 5, 2015

hey @st4lk can you rebase this? Should fix the tests.

@codecov-io
Copy link

Current coverage is 83.47%

Merging #140 into master will increase coverage by +0.09% as of 1f632c0

@@            master    #140   diff @@
======================================
  Files           22      22       
  Stmts         3756    3775    +19
  Branches         0       0       
  Methods          0       0       
======================================
+ Hit           3132    3151    +19
  Partial          0       0       
  Missed         624     624       

Review entire Coverage Diff as of 1f632c0

Powered by Codecov. Updated on successful CI builds.

@st4lk
Copy link
Author

st4lk commented Dec 4, 2015

I've done the rebase now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the format of the keywords dict should be documented.

In addition, it's a backward-incompatible change for client apps that pass keywords as code, so it should probably support the old format as well as the new one.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants