Translate the whole site to English: English routes with 301 redirects from the Dutch paths, English UI, docs, seeds and captions, one-time live content migration
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
PAGES = ["/", "/roll", "/standard", "/flyers", "/memes", "/people", "/people/retoor", "/join", "/terms", "/privacy", "/auth/login", "/docs", "/docs/welcome", "/docs/api/content"]
|
||||
DUTCH = ("Ik schrijf mee", "Mensen", "Binnen", "Voorwaarden", "Inloggen", "Meldingen", "Beheer", "Naar inhoud", "Nog niets", "Intro bewerken", "Een zes is", "Eenendertig", "Gezet in serif", "Verder lezen")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path", PAGES)
|
||||
def test_pages_are_english(anon, path):
|
||||
html = anon.get(path).text
|
||||
assert '<html lang="en">' in html
|
||||
assert 'content="en_US"' in html
|
||||
visible = re.sub(r"<script.*?</script>", "", html, flags=re.S)
|
||||
for word in DUTCH:
|
||||
assert word not in visible, (path, word)
|
||||
|
||||
|
||||
def test_nav_uses_english_paths(anon):
|
||||
html = anon.get("/").text
|
||||
for href, label in (("/roll", "Roll"), ("/standard", "Standard"), ("/people", "People"), ("/join", "Join")):
|
||||
assert f'href="{href}"' in html and f">{label}</a>" in html
|
||||
for old in ('href="/rol"', 'href="/standaard"', 'href="/mensen"', 'href="/binnen"', 'href="/voorwaarden"'):
|
||||
assert old not in html
|
||||
assert ">I'm in</a>" in html or ">I'm in</a>" in html
|
||||
|
||||
|
||||
def test_admin_sees_edit_intro(admin):
|
||||
html = admin.get("/").text
|
||||
assert "Edit intro" in html
|
||||
assert "Intro bewerken" not in html
|
||||
|
||||
|
||||
def test_sitemap_lists_english_paths(anon):
|
||||
xml = anon.get("/sitemap.xml").text
|
||||
for path in ("/roll<", "/standard<", "/people<", "/join<", "/terms<", "/docs/welcome<"):
|
||||
assert path in xml, path
|
||||
for old in ("/rol<", "/mensen", "/binnen", "/voorwaarden", "/docs/welkom"):
|
||||
assert old not in xml, old
|
||||
|
||||
|
||||
def test_gallery_captions_are_english(anon):
|
||||
flyers = anon.get("/flyers", headers={"Accept": "application/json"}).json()["items"]
|
||||
captions = {item["caption"] for item in flyers}
|
||||
assert "Thirty-one choices. You have zero." in captions
|
||||
assert not any(" geen " in f" {caption.lower()} " or " een " in f" {caption.lower()} " for caption in captions)
|
||||
|
||||
|
||||
def test_english_migration_helpers():
|
||||
from molodetz.bootstrap import _translate_notification
|
||||
|
||||
assert _translate_notification("Ada wil meeschrijven") == "Ada wants to write along"
|
||||
assert _translate_notification("Gepubliceerd: Geen cursus.") == "Published: No course."
|
||||
assert _translate_notification("Back-up database klaar") == "Backup database finished"
|
||||
assert _translate_notification("Je API-sleutel is vernieuwd.") == "Your API key was renewed."
|
||||
assert _translate_notification("Already English") == "Already English"
|
||||
Reference in New Issue
Block a user