Skip to content

feat(engine): Arabic interface, right to left - #36

Merged
DozenTwelve merged 1 commit into
DozenTwelve:mainfrom
mostafaelqaseir:arabic-rtl
Oct 31, 2026
Merged

DozenTwelve merged 1 commit into
DozenTwelve:mainfrom
mostafaelqaseir:arabic-rtl

Conversation

@mostafaelqaseir

Copy link
Copy Markdown
Contributor

Arabic interface, right to left

Adds Arabic as a built-in interface language and makes the player and the contents page read right to left for it, without changing what English (or any other language) renders.

What changes

  • Interface text. An ar block in TRANSLATIONS (engine.js, contents.js) with Arabic's plural forms (one, two, few 3–10, many 11–99, other). <html lang="ar"> sets dir="rtl" unless the page sets its own dir (RTL_LANGUAGES, one list in each file, kept in step like the translations).
  • Right to left, by logical properties. The left/right rules on cards, help, the finish screen, the contents and the unit art become logical (border-inline-start, inset-inline-end, padding-inline-start, text-align: start/end). In left-to-right pages they compute to the same values, so English is unchanged; in Arabic the cards, captions, help, cover and contents mirror.
  • What stays left to right. The stage, the player bar and mathematics (svg.m expressions and .bline answer lines in cards). Drawings keep their coordinates, seeking and ←/→ mean the same in every language (as YouTube does in Arabic), and 3 + 4 = [box] keeps its order, as in Arabic school books. Without this the first quick check rendered its equation scrambled.
  • Arabic type. Arabic letters join, so letter spacing is dropped on the uppercase kickers. Faces are each system's own Arabic UI and book faces (Segoe UI, SF Arabic/Geeza Pro, Noto); no font file is added to the books. A book's own book.css / theme still wins.
  • UI follows --ui. The engine's canvas measuring (and stage text) used a hard-coded face list; it now reads --ui, so an Arabic page (or a book that sets --ui) measures in the face it shows. The value is normalised so English markup stays byte-identical.
  • Narration. tts.py: ؟ ends a caption as ? does. I ran Edge's ar-SA-HamedNeural and ar-SA-ZariyahNeural live: every word boundary matched the text as written, with diacritics (إِنَّ), Arabic-Indic digits (٥) and inline maths (x + 3 = 7), so [[marks]] need no special handling. An old edge-tts gets HTTP 403 at the handshake; uv run --with edge-tts (as documented) takes the current one.

Checks

  • engine/check_i18n.py: new Arabic lesson and Arabic book checks (dir, LTR stage/bar, plurals, numbers, a key on an Arabic layout, the card's accent edge on the right, the equation's order, the step counter's order, the finish card, the cover arrow, contents and progress). "English unchanged against main" still passes, byte for byte.
  • .github/scripts/check_tts_text.py (new, stdlib only, added to CI): captions and marks from narration text with hand-written word timings, Arabic and English, no network.
  • engine/check_tapwords.py: the interface-strings check covers every language in TRANSLATIONS instead of a fixed list.
  • check_skill.py, check_site.py (engine copies synced with engine.py site), ruff, check_latex.py, check_tapwords.py, check_volume.py: all pass.

Docs

core/engine.md (what RTL does and keeps), core/publish.md (built-in languages), core/sound.md (Arabic voices and what was checked), lessons/diagrams.md (an Arabic page reads from the right, its maths from the left).

Not in this PR

  • Arabic-Indic digits in num() and answer boxes (digits stay 0–9 with a point).
  • eleven.py alignment for Arabic (not tested).
  • An Arabic book on the shelf (no copyrighted material, per CONTRIBUTING).
  • Books that install the Skill without the repository get this with the next engine-v* release.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SzbEL6yNpeuSXaqqgkchqD

…checked

- engine.js / contents.js: an Arabic block in TRANSLATIONS with its plural forms
  (one, two, few, many, other), and <html lang="ar"> sets dir="rtl" unless the page set one.
- engine.css / contents.css / units.css: physical left/right rules on cards, help, finish
  and contents become logical (border-inline-start, inset-inline-end, ...), so English renders
  as before and Arabic mirrors. The stage, the player bar and mathematics (svg.m, answer lines)
  stay left to right, so drawings, seeking and the arrow keys mean the same in every language.
  Arabic letters join: no letter spacing on the kickers; system Arabic faces, no font files.
- UI (canvas measuring and stage text) follows --ui, so an Arabic page measures in its own face.
- tts.py: ؟ ends a caption. Edge's ar-SA voices were checked live: their word boundaries match
  the text with diacritics, Arabic-Indic digits and inline maths.
- Checks: Arabic lesson and book in check_i18n.py (English output still identical to main),
  check_tts_text.py (captions and marks without a voice, added to CI), check_tapwords.py
  covers every interface language.
- Docs: engine.md, publish.md, sound.md, diagrams.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SzbEL6yNpeuSXaqqgkchqD
@DozenTwelve
DozenTwelve merged commit 7f8b1b6 into DozenTwelve:main Oct 31, 2026
2 checks passed
DozenTwelve added a commit that referenced this pull request Oct 31, 2026
PR #36 predates the book, so its engine copy is synced here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DozenTwelve

Copy link
Copy Markdown
Owner

Thank you, Mostafa! Merged and live at https://papermorph.diamonddoge.org/. A careful piece of work: logical properties so English stays byte-identical, the stage and maths kept left to right, and checks for all of it. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants