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

Single-line option to pygettext.py #41413

Closed
blais mannequin opened this issue Jan 9, 2005 · 7 comments
Closed

Single-line option to pygettext.py #41413

blais mannequin opened this issue Jan 9, 2005 · 7 comments
Labels
3.9 only security fixes 3.10 only security fixes type-feature A feature request or enhancement

Comments

@blais
Copy link
Mannequin

blais mannequin commented Jan 9, 2005

BPO 1098749
Nosy @abalkin, @merwok
Files
  • patch: Patch of pygettext.py against 2.4
  • issue1098749.diff: Patch against py3k revision 82959
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2005-01-09.03:01:53.000>
    labels = ['type-feature', '3.9', '3.10']
    title = 'Single-line option to pygettext.py'
    updated_at = <Date 2020-11-07.02:45:54.646>
    user = 'https://bugs.python.org/blais'

    bugs.python.org fields:

    activity = <Date 2020-11-07.02:45:54.646>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Demos and Tools']
    creation = <Date 2005-01-09.03:01:53.000>
    creator = 'blais'
    dependencies = []
    files = ['6422', '18055']
    hgrepos = []
    issue_num = 1098749
    keywords = ['patch']
    message_count = 7.0
    messages = ['47502', '47503', '59750', '110703', '114992', '203395', '203396']
    nosy_count = 5.0
    nosy_names = ['nobody', 'blais', 'belopolsky', 'eric.araujo', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1098749'
    versions = ['Python 3.9', 'Python 3.10']

    @blais
    Copy link
    Mannequin Author

    blais mannequin commented Jan 9, 2005

    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 $(PROJECT) -p $(dir $@) $(PYFILES)

    cheers,

    @nobody
    Copy link
    Mannequin

    nobody mannequin commented Sep 22, 2005

    Logged In: NO

    Code review....

    You have a few lines like :
    s = '%s' % ' '.join(newlines)
    Surely that is the same as just:
    s = ' '.join(newlines)

    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)

    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.

    @akuchling
    Copy link
    Member

    Is this change still useful for 2.6?

    @abalkin
    Copy link
    Member

    abalkin commented Jul 19, 2010

    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 bpo-7962 so that the fate of this patch and pygettext itself can be decided.

    @abalkin abalkin added type-feature A feature request or enhancement labels Jul 19, 2010
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Aug 26, 2010

    My gut reaction is that pygettext should be deprecated, other opinions are welcome.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 19, 2013

    New changeset 4fe87b5df2d0 by Andrew Kuchling in branch '3.3':
    bpo-1098749: re-word gettext docs to not encourage using pygettext so much.
    http://hg.python.org/cpython/rev/4fe87b5df2d0

    @akuchling
    Copy link
    Member

    I've applied a patch from bpo-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.

    @iritkatriel iritkatriel added 3.9 only security fixes 3.10 only security fixes labels Nov 7, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    @iritkatriel iritkatriel closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes type-feature A feature request or enhancement
    Projects
    Status: Done
    Development

    No branches or pull requests

    3 participants