From f68071cb51ba6c1e4aadd622820e27e944bac720 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Mon, 28 Sep 2026 06:26:13 +0000 Subject: [PATCH] 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. --- pagerite/translate.py | 22 ++++++++++++++++++++++ pagerite/views.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pagerite/translate.py b/pagerite/translate.py index 4e28883..ab3648c 100644 --- a/pagerite/translate.py +++ b/pagerite/translate.py @@ -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) diff --git a/pagerite/views.py b/pagerite/views.py index 515c0b8..1b05843 100644 --- a/pagerite/views.py +++ b/pagerite/views.py @@ -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,