Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pygettext: Extend support for specifying custom keywords #130453

Open
Assignees
tomasr8
Labels
triagedThe issue has been accepted as valid by a triager.type-featureA feature request or enhancement
@tomasr8

Description

@tomasr8

Feature or enhancement

Proposal:

pygettext already allows specifying custom keywords in a limited fashion. For example, specifying--keyword=foo will
look for functions namedfoo in addition to the default keywords (gettext, etc..).

However, the CLI currently only allows specifying single-argument functions (i.e.gettext('foo')). It is not possible to add
keywords that takemsgid_plural ormsgctxt or both.

Both xgettext and babel support this with asimple keywordspec syntax that defines the function name and argument positions ofmsgid,msgid_plural andmsgctxt.

For example,--keyword:foo:1c,2 defines apgettext-like function where themsgctxt is the first argument andmsgid is the second argument, e.g.foo('context', 'message').

It is also possible to uset to only match functions with that exact number of arguments. For example,foo:1,1t only matchesfoo('bar') but notfoo('bar', 'baz').

I propose to support this in pygettext as well. For that we will need to:

  • Support the keyword spec syntax when specifying keywords. I suggest skipping thet specifier for now.
  • Support specifying multiple--keyword arguments with the same function name (this will require some internal changes, as those are stored in a dictionary with the function name as the key).
  • Support thet specifier.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

Labels

triagedThe issue has been accepted as valid by a triager.type-featureA feature request or enhancement

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2026 Movatter.jp