Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Review actions.
  • Loading branch information
jcsteh committed Aug 14, 2017
commit 3f3d1fb28127529fc82ce405c366be30903bb383
11 changes: 11 additions & 0 deletions tests/checkPot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor

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?

# 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',
Expand Down Expand Up @@ -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
Expand All @@ -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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 "'):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's probably assumed knowledge for this, but what are: msgctxt, msgid, msgstr. Are these concepts from some other library module? Either a brief explanation of what they are or a pointer to where to find out about them could be handy for someone who comes to maintain this without that background knowledge.

# 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:
Expand Down