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


##########
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:
   Agreed. `96d0540834` removes the pinned count and the pinned `Backend` 
wording, and it also covers a second case.
   
   Most PRs commit only `messages.pot`. On master at `1cf9569807`, every 
catalog lags the template by 18 msgids. A test that reads the committed 
catalogs fails for a contributor who adds a note this way. For a note on a new 
string, it failed with `AttributeError`.
   
   The new test builds a template and a catalog in a temporary directory. It 
reads the `pybabel update` call from `babel_update.sh`, replaces only the `-i` 
and `-d` paths, and runs it. It then reads the note back. It covers an added, a 
reworded, a removed and a wrapped note. Adding `-l fr` to the script's update 
call fails all four cases. The PR description has the scenario matrix and the 
negative controls.
   



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