Skip to content

Add some missing translator comments and check for missing translator comments in future#7492

Merged
jcsteh merged 2 commits into
masterfrom
transComments
Aug 29, 2017
Merged

Add some missing translator comments and check for missing translator comments in future#7492
jcsteh merged 2 commits into
masterfrom
transComments

Conversation

@jcsteh

@jcsteh jcsteh commented Aug 14, 2017

Copy link
Copy Markdown
Contributor

Link to issue number:

None specifically, but inspired by an omition in #7258.

Summary of the issue:

All translatable strings should have translator comments explaining them to translators. However, this is sometimes forgotten and this is easy to miss in review.

Description of how this pull request fixes the issue:

  1. Add a few missing translator comments inspired by reports from translators.
  2. Add some code (checkPot) to check for missing translator comments in the translation template (pot). For now, we have a set of expected failures, since fixing all existing 87 messages that don't have translator comments is going to take some work. However, we want to fail for any new messages that get introduced without comments.
  3. Run checkPot as part of scons tests. This means tests (and thus builds) will fail so we learn about these problems early.
  4. checkPot can also be run alone with scons checkPot.
  5. Now that scons tests runs checkPot (which depends on pot), don't explicitly run scons pot on AppVeyor.

Testing performed:

  1. Tested that unexpected errors cause checkPot to fail.
  2. Tested that expected errors don't cause checkPot to fail, but do get counted in the summary.
  3. Added a message that already has a translator comment to the EXPECTED_MESSAGES_WITHOUT_COMMENTS set. Tested that this causes an unexpected success and that checkPot fails as a result.
  4. Tested that scons tests runs checkPot.
  5. Tested that scons tests unitTests=test_cursorManager does not run checkPot (since explicit tests were specified).
  6. Tested that an unexpected error causes an AppVeyor build to fail.

Known issues with pull request:

None.

Change log entry:

Changes for developers:

- "scons tests" now checks that translatable strings have translator comments. You can also run this alone with "scons checkPot". (#7492)

@jcsteh jcsteh requested a review from feerrenrut August 14, 2017 02:44
@jcsteh jcsteh force-pushed the transComments branch 2 times, most recently from 141fc62 to a60a8c7 Compare August 14, 2017 02:58
… comments in future.

1. Add a few missing translator comments inspired by reports from translators.
2. Add some code (`checkPot`) to check for missing translator comments in the translation template (pot). For now, we have a set of expected failures, since fixing all existing 87 messages that don't have translator comments is going to take some work. However, we want to fail for any new messages that get introduced without comments.
3. Run `checkPot` as part of `scons tests`. This means tests (and thus builds) will fail so we learn about these problems early.
4. `checkPot` can also be run alone with `scons checkPot`.
5. Now that `scons tests` runs `checkPot` (which depends on `pot`), don't explicitly run `scons pot` on AppVeyor.
@jcsteh

jcsteh commented Aug 14, 2017

Copy link
Copy Markdown
Contributor Author

@michaelDCurran ended up fixing the string in #7258 in master 890528b. I've modified this PR accordingly.

@feerrenrut feerrenrut left a comment

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.

Looks good overall, just few comments.

Comment thread tests/checkPot.py
# Existing messages that we know don't have translator comments yet.
# 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?

Comment thread tests/checkPot.py
hasComment = True
continue
if line.startswith("#: "):
# 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..."

Comment thread tests/checkPot.py
expectedErrors += 1
continue
if hasComment and isExpectedError:
error = ("Message has translator comment, but one wasn't expected.\n"

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.

Oh, turns out you do report this case. Great!

Comment thread tests/checkPot.py
# 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.

@jcsteh

jcsteh commented Aug 14, 2017 via email

Copy link
Copy Markdown
Contributor Author

jcsteh added a commit that referenced this pull request Aug 15, 2017
@jcsteh jcsteh merged commit 5b636a3 into master Aug 29, 2017
@nvaccessAuto nvaccessAuto added this to the 2017.4 milestone Aug 29, 2017
@jcsteh jcsteh deleted the transComments branch August 29, 2017 23:05
JulienCochuyt added a commit to accessolutions/nvda that referenced this pull request May 3, 2020
…slatable strings

 - Ensured `checkPot` does not mistake a lengthy `msgid` with the POT file header
 - Added 5 additional known messages without translators comment with reference to their location in the source
 - Added 1 missing translators comment
 - Linted 25 existing translators comment so that they now properly land in the POT file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants