Repository navigation
Add some missing translator comments and check for missing translator comments in future #7492
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ | |
| # Ideally, all of these should get translator comments, | ||
| # but this is not realistic right now. | ||
| # A message should be removed from here once a translator comment is added for it. | ||
| # Note that checkPot will fail with an unexpected success | ||
| # if a translator comment is found for one of these messages. | ||
| EXPECTED_MESSAGES_WITHOUT_COMMENTS = { | ||
| 'Focus mode', | ||
| '%s landmark', | ||
|
|
@@ -107,6 +109,10 @@ def checkPot(fileName): | |
| """Returns the number of errors. | ||
| Also prints error messages and a summary to standard output. | ||
| """ | ||
| # This function reads a gettext translation template (pot) line by line, | ||
| # parsing only the content it needs. | ||
| # See this link for info about the format of gettext translation files: | ||
| # https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html | ||
| errors = 0 | ||
| expectedErrors = 0 | ||
| unexpectedSuccesses = 0 | ||
|
|
@@ -123,25 +129,30 @@ def checkPot(fileName): | |
| # Header. | ||
| continue | ||
| if line.startswith("#. Translators: "): | ||
| # This is a comment for translators. | ||
| # Example: "#. Translators: a message reported in the SetRowHeader script for Microsoft Word." | ||
| hasComment = True | ||
| continue | ||
| if line.startswith("#: "): | ||
| # This specifies the files and line numbers where this message was found. | ||
| # Example: "#: NVDAObjects\window\winword.py:1322" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused by this, is this saying go and look at winword.py line 1322 for an example, or is the path part of the example? If so (the path case) it might be handy to add some further explanation text. EG "Sometimes we include paths in the translator comments, and so we must handle these because..." |
||
| # Strip the "#: " prefix (3 chars). | ||
| sourceLines.append(line[3:]) | ||
| continue | ||
| if line.startswith('msgctxt "'): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably assumed knowledge for this, but what are: |
||
| # This is the context used to disambiguate messages. | ||
| context = getStringFromLine(line) | ||
| continue | ||
| if line.startswith("msgid "): | ||
| # This is the untranslated message. | ||
| # Get the message. | ||
| if line == 'msgid ""': | ||
| # Multi-line msgid. | ||
| # Subsequent lines are just quoted strings which should be concatenated. | ||
| msgid = "" | ||
| for line in pot: | ||
| if line.startswith("msgstr "): | ||
| # This begins the translated message, so msgid has ended. | ||
| break | ||
| msgid += getStringFromLine(line) | ||
| else: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the test fail if the exception is incorrectly specified? EG if someone adds a translator comment for one of these, and forgets to remove it from the exception list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found out it does, could you update this comment to specify that it does?