Files
Pulse/scripts/tests/test_localized_public_docs.py
rcourtman c30664475f Add French to the localized surfaces and getting-started guide
French-speaking operators asked for the surfaces already localized in
German and Spanish (issue 2886, discussion 2267). French joins the
first wave: a lazily loaded catalog for every migrated key, the
Français option in Settings, fr-* browser detection and a French
getting-started guide mirrored to the in-app docs.

The catalog starts from the reporter's offered translation, brought up
to current main: 36 retired keys dropped, 11 new keys translated, and
two strings whose English changed since then retranslated. Count labels
use count-neutral wording because these keys have no plural forms.

With four options the language row no longer fit a 375px screen, so
it stacks under its label on phones; desktop layout is unchanged.

Original-contribution: https://github.com/rcourtman/Pulse/issues/2886
Co-authored-by: Ivan Gallais <ivan.gallaissfr.fr@gmail.com>
2026-11-02 12:02:33 +00:00

105 lines
3.9 KiB
Python

#!/usr/bin/env python3
"""Guardrails for first-wave localized public docs."""
from __future__ import annotations
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[2]
def read(rel: str) -> str:
return (ROOT / rel).read_text(encoding="utf-8")
LOCALIZED_DOCS = (
"docs/i18n/de/README.md",
"docs/i18n/es/README.md",
"docs/i18n/fr/README.md",
)
MACHINE_FACING_STRINGS = (
"export PULSE_VERSION=vX.Y.Z",
"curl -fsSLO \"https://github.com/rcourtman/Pulse/releases/download/${PULSE_VERSION}/install.sh\"",
"curl -fsSLO \"https://github.com/rcourtman/Pulse/releases/download/${PULSE_VERSION}/install.sh.sshsig\"",
"ssh-keygen -Y verify",
"bash install.sh --version \"${PULSE_VERSION}\"",
"docker run -d",
"rcourtman/pulse:vX.Y.Z",
"image: ${PULSE_IMAGE:-rcourtman/pulse:vX.Y.Z}",
"docker exec pulse /app/pulse bootstrap-token",
"kubectl exec -it <pod> -- /app/pulse bootstrap-token",
"sudo pulse bootstrap-token",
"Settings → Infrastructure → Install on a host",
"Settings → Plans & Billing → License recovery",
"ppk_live_",
"http://<your-ip>:7655",
"/install.sh",
"https://pulserelay.pro/download.html",
)
class LocalizedPublicDocsTest(unittest.TestCase):
def test_public_indexes_link_to_localized_getting_started_docs(self) -> None:
root_readme = read("README.md")
docs_index = read("docs/README.md")
self.assertIn("[Deutsch](docs/i18n/de/README.md)", root_readme)
self.assertIn("[Español](docs/i18n/es/README.md)", root_readme)
self.assertIn("[Français](docs/i18n/fr/README.md)", root_readme)
self.assertIn("[Deutsch](i18n/de/README.md)", docs_index)
self.assertIn("[Español](i18n/es/README.md)", docs_index)
self.assertIn("[Français](i18n/fr/README.md)", docs_index)
def test_localized_docs_preserve_machine_facing_strings(self) -> None:
for rel in LOCALIZED_DOCS:
content = read(rel)
for value in MACHINE_FACING_STRINGS:
with self.subTest(path=rel, value=value):
self.assertIn(value, content)
def test_localized_docs_point_back_to_canonical_english_docs(self) -> None:
for rel in LOCALIZED_DOCS:
content = read(rel)
with self.subTest(path=rel):
self.assertIn("[docs/README.md](../../README.md)", content)
self.assertIn("[Installation Guide](../../INSTALL.md)", content)
self.assertIn("[Configuration](../../CONFIGURATION.md)", content)
self.assertIn("[Troubleshooting](../../TROUBLESHOOTING.md)", content)
self.assertIn("[Agent Security](../../AGENT_SECURITY.md)", content)
self.assertIn("[Plans and entitlements](../../PULSE_PRO.md)", content)
def test_localized_compose_uses_bootstrap_not_shared_credentials(self) -> None:
for rel in LOCALIZED_DOCS:
content = read(rel)
with self.subTest(path=rel):
self.assertNotIn("secret123", content)
self.assertNotIn("PULSE_AUTH_USER=", content)
self.assertNotIn("PULSE_AUTH_PASS=", content)
self.assertIn("../../CONFIGURATION.md#private-docker-authentication-file", content)
self.assertIn("docker exec pulse /app/pulse bootstrap-token", content)
def test_localized_docs_do_not_reintroduce_paid_capacity_claims(self) -> None:
forbidden = (
"unlimited",
"uncapped",
"no cap",
"no-cap",
"sin límite",
"ilimitado",
"illimité",
"sans limite",
"unbegrenzt",
)
for rel in LOCALIZED_DOCS:
content = read(rel).lower()
for phrase in forbidden:
with self.subTest(path=rel, phrase=phrase):
self.assertNotIn(phrase, content)
if __name__ == "__main__":
unittest.main()