glaterza commented on code in PR #44397:
URL: https://github.com/apache/superset/pull/44397#discussion_r4134402930
##########
superset/translations/messages.pot:
##########
@@ -2536,6 +2536,8 @@ msgstr ""
msgid "Back to all"
msgstr ""
+#. i18n: the database engine behind a connection (PostgreSQL, MySQL),
Review Comment:
Not a deliberate choice. I regenerated only the template and left the
catalogs to the next `babel_update.sh` run, but you're right that translators
work in the catalogs, so that's where the context has to be. (For what it's
worth, it's mixed upstream: of the last seven PRs that touched `messages.pot`,
one also regenerated the catalogs.)
Added in 1357bc4ce4. The four `#. i18n:` comments are now on the matching
entries in all 30 catalogs, 120 entries and 180 lines, and nothing else
changes. I didn't run a full `pybabel update`, because that would also pull in
every unrelated string change since the catalogs were last regenerated. Instead
I checked the result against it: I ran `pybabel update` with the script's flags
on a copy, and all 120 entries come out identical. The German catalog shows why
this matters: `Slug` is translated there as `Kopfzeile` ("header").
##########
tests/unit_tests/scripts/translations/check_pot_drift_test.py:
##########
@@ -236,3 +237,18 @@ def test_committed_template_matches_a_fresh_extraction()
-> None:
missing, stale = check_pot_drift.diff()
assert not missing, f"{len(missing)} string(s) in source missing from
messages.pot"
assert not stale, f"{len(stale)} string(s) in messages.pot no longer in
source"
+
+
+def test_extract_flags_match_babel_update_sh() -> None:
+ """``EXTRACT_FLAGS`` mirrors the ``pybabel extract`` call in
babel_update.sh.
+
+ Only ``-F`` and ``-o`` differ, since the drift check writes to a temporary
+ path. Any other flag added to one invocation and not the other fails here.
+ """
+ script = (_SCRIPT_PATH.parent /
"babel_update.sh").read_text(encoding="utf-8")
+ command = script[script.index("\npybabel extract") :]
+ command = command[: command.index(" .\n") + 2].replace("\\\n", " ")
+ args = shlex.split(command)[2:]
+ for flag in ("-F", "-o"):
+ del args[args.index(flag) : args.index(flag) + 2]
+ assert args == check_pot_drift.EXTRACT_FLAGS
Review Comment:
Agreed, the parity test can't see the flag being dropped from both
invocations. Added `test_extraction_carries_i18n_comments_to_the_template` in
1357bc4ce4. It runs the real `pybabel extract` with `EXTRACT_FLAGS` over a
small Python file and a TypeScript file. Then it asserts that each
`i18n:`-tagged comment lands on its entry, and that an ordinary code comment
doesn't.
I checked your exact scenario: removing `--add-comments=i18n:` from both
`babel_update.sh` and `EXTRACT_FLAGS` keeps the parity test green and fails the
new one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]