glaterza commented on code in PR #44397:
URL: https://github.com/apache/superset/pull/44397#discussion_r4145384166
##########
scripts/translations/babel_update.sh:
##########
@@ -40,11 +40,18 @@ cat <<'EOF'> "$LICENSE_TMP"
EOF
cd $ROOT_DIR
+# --add-comments=i18n:: carry translator context from the source into the
+# catalogs. A comment tagged `i18n:` immediately above a translatable string is
+# extracted as a `#. i18n: ...` comment on that entry, and (like the
+# do-not-translate marker below) propagates into every language catalog on the
+# `pybabel update` further down. Only `i18n:`-tagged comments are extracted, so
+# ordinary code comments near a string are not published to translators.
pybabel extract \
-F superset/translations/babel.cfg \
-o superset/translations/messages.pot \
--no-location \
--sort-output \
+ --add-comments=i18n: \
Review Comment:
Done in 7ccf383b48. `backfill_po.py` now sends the `i18n:` comment to the
model as a "Developer note", in both the batch prompt and the single-string
fallback. The prompt says the note outranks the reference translations, because
those can be wrong themselves. For `Slug` they include Dutch "Slak" (the
animal), and for `Backend` Russian "Драйвер" ("driver").
I also tested it live with the script's default model, giving it only
misleading references. Without the note, `Backend` came back as "driver" in 3
of 6 runs; with it, 0 of 6. With the real references it made no difference.
##########
scripts/translations/check_pot_drift.py:
##########
@@ -56,10 +56,12 @@
ROOT_DIR = Path(__file__).resolve().parent.parent.parent
DEFAULT_POT = ROOT_DIR / "superset" / "translations" / "messages.pot"
-# Kept in sync with the `pybabel extract` invocation in babel_update.sh.
+# Kept in sync with the `pybabel extract` invocation in babel_update.sh
+# (enforced by check_pot_drift_test.py).
EXTRACT_FLAGS = [
"--no-location",
"--sort-output",
+ "--add-comments=i18n:",
Review Comment:
Done in 7ccf383b48. The drift check now also compares each string's `i18n:`
comments against a fresh extraction. A changed, added or removed comment fails,
and is listed with `~`. The comparison is word by word, so re-wrapping isn't
drift. The `do-not-translate` marker is excluded, because it's added after
extraction.
Checked on real source: rewording the `Slug` comment fails with `~ 'Slug'`,
and reverting it passes.
--
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]