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,