contact messages: translator service picks up the site contact strings

pending_items emits the effective contact label/subject as title-kind
fragments (chunk-keyed trans storage, like node titles), and nav-mode
jobs carry them as extra top-level list items, so Seed-X and LLM
translators localize the contact chrome with the menu. Manual overrides
land in the same store via i18n.set_string_translation.
This commit is contained in:
LeoVasanko committed 2026-09-28 06:26:13 +00:00
1 parent 2adafd215b
commit f68071cb51
2 files changed
+23 -1

No files matched your search

+22
View File
@@ -309,6 +309,15 @@ def pending_items(data: Data, lang: str) -> list[TransItem]:
walk(node.children, path, node_lang)
walk(data.menu, "", i18n.ORIGINAL_LANGUAGE)
# Site-level messaging strings (Data.contact_label/contact_subject):
# translated like titles and looked up at render time by chunk key
# (i18n.site_string) — the EFFECTIVE label, so the built-in default
# localizes too. Skipped in the site default language, like titles in
# their article's primary language.
if data.contact_enabled and lang != i18n.primary_lang(data.menu, ""):
for text in (data.contact_label or "Contact us", data.contact_subject):
if text and "\n" not in text:
emit(chunk_key(text), text, "", "title")
return items
@@ -536,6 +545,19 @@ class Dispatcher:
walk(node.children, depth + 1, node_lang)
walk(self.data.menu, 0, i18n.ORIGINAL_LANGUAGE)
# The site-level messaging strings ride the same list (pending_items
# covers them for scoped jobs): one round trip names the menu and
# the contact chrome alike.
if self.data.contact_enabled and lang != i18n.primary_lang(self.data.menu, ""):
for text in (self.data.contact_label or "Contact us", self.data.contact_subject):
if text and "\n" not in text:
key = chunk_key(text)
if (
lang not in self.data.trans.get(key, {})
and (lang, key) not in inflight
and (lang, key, "nav") not in self.validation_failures
):
titles.append((0, text, key))
if len(titles) < 2:
return None
md = "\n".join(f"{' ' * depth}- {title}" for depth, title, _ in titles)
+1 -1
View File
@@ -1012,7 +1012,7 @@ def _contact_config(data: Data, lang: str) -> dict[str, str]:
the visitor dialog's title, the mailto address and its subject (the
label when no separate subject is configured). Translations come from
the chunk-keyed trans store (i18n.site_string)."""
label = i18n.site_string(data, lang, data.contact_label) or "Contact us"
label = i18n.site_string(data, lang, data.contact_label or "Contact us")
return {
"label": label,
"email": data.contact_email,