-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-130057: Pygettext: Support translator comments #130061
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
22249e8
pygettext: Support translator comments
tomasr8 cab4b7a
Add news entry
tomasr8 a86fb59
Make linter happy
tomasr8 d496031
Merge branch 'main' into translator-comments
tomasr8 396a7be
Only process comments when needed
tomasr8 feb1145
Make --add-comments optional
tomasr8 fd480bb
Strip any leading '#' and whitespace from comments
tomasr8 b3f6b48
Add missing newline
tomasr8 91f5e97
Remove extra newline
tomasr8 aef1e0b
Use string.lstrip instead of re.sub
tomasr8 7b98ba8
Test multiple comment tags
tomasr8 d9ae563
Test comments are not extracted unless a tag is given
tomasr8 56999b4
Add more tests
tomasr8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR ORGANIZATION | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2000-01-01 00:00+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Generated-By: pygettext.py 1.5\n" | ||
|
||
|
||
#: comments.py:4 | ||
msgid "foo" | ||
msgstr "" | ||
|
||
#. i18n: This is a translator comment | ||
#: comments.py:7 | ||
msgid "bar" | ||
msgstr "" | ||
|
||
#. i18n: This is a translator comment | ||
#. i18n: This is another translator comment | ||
#: comments.py:11 | ||
msgid "baz" | ||
msgstr "" | ||
|
||
#. i18n: This is a translator comment | ||
#. with multiple | ||
#. lines | ||
#: comments.py:16 | ||
msgid "qux" | ||
msgstr "" | ||
|
||
#. i18n: This is a translator comment | ||
#: comments.py:21 | ||
msgid "quux" | ||
msgstr "" | ||
|
||
#. i18n: This is a translator comment | ||
#. with multiple lines | ||
#. i18n: This is another translator comment | ||
#. with multiple lines | ||
#: comments.py:27 | ||
msgid "corge" | ||
msgstr "" | ||
|
||
#: comments.py:31 | ||
msgid "grault" | ||
msgstr "" | ||
|
||
#. i18n: This is another translator comment | ||
#: comments.py:36 | ||
msgid "garply" | ||
msgstr "" | ||
|
||
#: comments.py:40 | ||
msgid "george" | ||
msgstr "" | ||
|
||
#. i18n: This is another translator comment | ||
#: comments.py:45 | ||
msgid "waldo" | ||
msgstr "" | ||
|
||
#. i18n: This is a translator comment | ||
#. i18n: This is also a translator comment | ||
#. i18n: This is another translator comment | ||
#: comments.py:50 | ||
msgid "waldo2" | ||
msgstr "" | ||
|
||
#. i18n: This is a translator comment | ||
#. i18n: This is another translator comment | ||
#. i18n: This is yet another translator comment | ||
#. i18n: This is a translator comment | ||
#. with multiple lines | ||
#: comments.py:53 comments.py:56 comments.py:59 comments.py:63 | ||
msgid "fred" | ||
msgstr "" | ||
|
||
#: comments.py:65 | ||
msgid "plugh" | ||
msgstr "" | ||
|
||
#: comments.py:67 | ||
msgid "foobar" | ||
msgstr "" | ||
|
||
#. i18n: This is a translator comment | ||
#: comments.py:71 | ||
msgid "xyzzy" | ||
msgstr "" | ||
|
||
#: comments.py:72 | ||
msgid "thud" | ||
msgstr "" | ||
|
||
#. i18n: This is a translator comment | ||
#. i18n: This is another translator comment | ||
#. i18n: This is yet another translator comment | ||
#: comments.py:78 | ||
msgid "foos" | ||
msgstr "" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from gettext import gettext as _ | ||
|
||
# Not a translator comment | ||
_('foo') | ||
|
||
# i18n: This is a translator comment | ||
_('bar') | ||
|
||
# i18n: This is a translator comment | ||
# i18n: This is another translator comment | ||
_('baz') | ||
|
||
# i18n: This is a translator comment | ||
# with multiple | ||
# lines | ||
_('qux') | ||
|
||
# This comment should not be included because | ||
# it does not start with the prefix | ||
# i18n: This is a translator comment | ||
_('quux') | ||
|
||
# i18n: This is a translator comment | ||
# with multiple lines | ||
# i18n: This is another translator comment | ||
# with multiple lines | ||
_('corge') | ||
|
||
# i18n: This comment should be ignored | ||
|
||
_('grault') | ||
|
||
# i18n: This comment should be ignored | ||
|
||
# i18n: This is another translator comment | ||
_('garply') | ||
|
||
# i18n: comment should be ignored | ||
x = 1 | ||
_('george') | ||
|
||
# i18n: This comment should be ignored | ||
x = 1 | ||
# i18n: This is another translator comment | ||
_('waldo') | ||
|
||
# i18n: This is a translator comment | ||
x = 1 # i18n: This is also a translator comment | ||
# i18n: This is another translator comment | ||
_('waldo2') | ||
|
||
# i18n: This is a translator comment | ||
_('fred') | ||
|
||
# i18n: This is another translator comment | ||
_('fred') | ||
|
||
# i18n: This is yet another translator comment | ||
_('fred') | ||
|
||
# i18n: This is a translator comment | ||
# with multiple lines | ||
_('fred') | ||
|
||
_('plugh') # i18n: This comment should be ignored | ||
|
||
_('foo' # i18n: This comment should be ignored | ||
'bar') # i18n: This comment should be ignored | ||
|
||
# i18n: This is a translator comment | ||
_('xyzzy') | ||
_('thud') | ||
|
||
|
||
## i18n: This is a translator comment | ||
# # i18n: This is another translator comment | ||
### ### i18n: This is yet another translator comment | ||
_('foos') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Tools-Demos/2025-02-12-23-24-37.gh-issue-130057.TKUKI6.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add support for translator comments in :program:`pygettext.py`. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.