sadpandajoe commented on code in PR #44397:
URL: https://github.com/apache/superset/pull/44397#discussion_r4201696935


##########
tests/unit_tests/scripts/translations/backfill_po_test.py:
##########
@@ -545,10 +575,129 @@ def _fake_translate_batch(
     # DNT entries never reached the translator …
     assert "bolt" not in seen_msgids
     assert "Keep me literal" not in seen_msgids
-    assert seen_msgids == ["Save dashboard"]
+    assert seen_msgids == ["Slug", "Save dashboard"]
 
     # … and stay untranslated in the written file, while the normal one is 
filled.
     written = polib.pofile(str(po_path))
     assert written.find("bolt").msgstr == ""
     assert written.find("Keep me literal").msgstr == ""
+    assert written.find("Slug").msgstr == "T:Slug"
     assert written.find("Save dashboard").msgstr == "T:Save dashboard"
+
+
+# --- i18n: developer notes -------------------------------------------------
+
+_BACKEND_NOTE = (
+    "the kind of system behind a connection: a database engine "
+    "(PostgreSQL, MySQL) or a semantic layer; not a server tier or a driver"
+)
+
+
[email protected](
+    ("comment", "expected"),
+    [
+        ("i18n: a URL identifier, not the animal", "a URL identifier, not the 
animal"),
+        (
+            "i18n: the kind of system behind a connection: a database engine\n"
+            "(PostgreSQL, MySQL) or a semantic layer; not a server tier or a 
driver",
+            _BACKEND_NOTE,
+        ),
+        ("i18n: a URL identifier\ndo-not-translate", "a URL identifier"),
+        ("do-not-translate\ni18n: a URL identifier", "a URL identifier"),
+        # A note may say "do not translate" in prose; only the exact stamped
+        # marker line ends it.
+        (
+            "i18n: the product name,\ndo not translate it",
+            "the product name, do not translate it",
+        ),
+        ("i18n: first note\ni18n: second note", "first note second note"),
+        ("do-not-translate", None),
+        ("", None),
+    ],
+)
+def test_developer_note_reads_the_i18n_comment(
+    comment: str, expected: str | None
+) -> None:
+    entry = polib.POEntry(msgid="Slug", msgstr="", comment=comment)
+    assert backfill_po._developer_note(entry) == expected
+
+
+def test_developer_note_reads_the_committed_catalogs() -> None:
+    """Every catalog carries the four notes exactly as the template states 
them."""
+    translations = _SCRIPT_PATH.parents[2] / "superset" / "translations"
+    template = polib.pofile(str(translations / "messages.pot"))
+    expected = {
+        entry.msgid: backfill_po._developer_note(entry)
+        for entry in template
+        if backfill_po._developer_note(entry)
+    }
+    assert expected["Backend"] == _BACKEND_NOTE
+    assert len(expected) == 4

Review Comment:
   These two assertions pin the catalogs to exactly four notes and to the 
current `Backend` wording. Following the new howto and adding a fifth `i18n:` 
note (or rewording one), with the template and all catalogs regenerated in 
sync, would still fail CI here until someone edits this test. Should the fixed 
examples live in a fixture, with this check asserting only that every catalog 
carries each note the template does?



-- 
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]

Reply via email to