Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

feat(engine): Arabic interface, right to left, with Arabic narration checked

Mostafa89d8b44e8cfa
diff --git a/.claude/skills/papermorph/references/core/engine.md b/.claude/skills/papermorph/references/core/engine.md
index 66a8a45..1806683 100644
--- a/.claude/skills/papermorph/references/core/engine.md
+++ b/.claude/skills/papermorph/references/core/engine.md
@@ -1,6 +1,6 @@
# The engine (lib/engine.js, lib/engine.css, lib/math.js)
-A chapter page loads the engine and its `audio/<lang>/timings.js`, defines `CHAPTER` (with `language` when not `en`: the audio folder), drawing helpers, `BEATS` and questions, then calls `boot()`. The engine provides the stage, drawing, timeline, question types, guide and player; where the code's signatures differ from this reference, the code wins. Interface text (buttons, help, cover, finish card) follows `<html lang>`: English, Russian, Chinese and Japanese are in the engine's `TRANSLATIONS`; another language needs a block there.
+A chapter page loads the engine and its `audio/<lang>/timings.js`, defines `CHAPTER` (with `language` when not `en`: the audio folder), drawing helpers, `BEATS` and questions, then calls `boot()`. The engine provides the stage, drawing, timeline, question types, guide and player; where the code's signatures differ from this reference, the code wins. Interface text (buttons, help, cover, finish card) follows `<html lang>`: English, Russian, Chinese, Japanese and Arabic are in the engine's `TRANSLATIONS`; another language needs a block there and in `contents.js`. Arabic also turns the page right to left (`RTL_LANGUAGES`): cards, captions, help, the cover and the contents read from the right, while the stage, the player bar and mathematics (expressions and answer lines in cards) keep their left-to-right order, as in Arabic school books. So a chapter draws in the same coordinates and ←/→ step the same way in every language; on the stage an `end` anchor is still a text's right end. Arabic letters join, so the engine drops letter spacing on its uppercase kickers; give a book's own Arabic headings `letter-spacing: 0` too.
Every book keeps a copy of the shared engine in `lib/` (`engine.*`, `math.js`, `volume.*`, `contents.*`, `units.*`), so the book runs on its own. The engine is not part of this skill but lives in the `engine/` folder of the Papermorph repository (or a fork). `python3 SKILL/scripts/engine.py site` copies it into every book from the repository's `engine/` when it is at hand, otherwise from GitHub (`--check` lists copies that differ, `--from DIR|OWNER/REPO@REF` picks the source, by default the latest compatible release, `engine-v2.8`; `@main` takes the newest, a tag or commit pins it, and `engine-v1` is the last engine with the maths helpers inside `engine.js`); a book's copy is not edited by hand. This reference describes `engine-v2.8`: sync a book on an older copy before relying on anything here. Fix an engine bug at the source, then sync. The book's own settings and style overrides live in `lib/book.css`, imported by `engine.css` and never overwritten: `--math-font` for numbers and formulas, `--progress-key` when the cover uses a key other than the default.
diff --git a/.claude/skills/papermorph/references/core/publish.md b/.claude/skills/papermorph/references/core/publish.md
index a9ea895..1b21b6f 100644
--- a/.claude/skills/papermorph/references/core/publish.md
+++ b/.claude/skills/papermorph/references/core/publish.md
@@ -14,7 +14,7 @@ It runs `engine.py` into `site/<book>/lib/` (the engine, plus `lib/book.css` for
## Every book
-- Use the agreed primary language: the narration source is `narration.<lang>.json`, the chapter loads `audio/<lang>/timings.js`, and `CHAPTER.language` matches (default `en`; it picks the audio folder). Set the same `<html lang>` in `index.html` and every chapter: the player and the contents page take their interface text from it (English, Russian, Chinese and Japanese are built in; other languages fall back to English until a block is added to the engine's `TRANSLATIONS`). Take `voice` and `rate` from `style.json`, and translate the template's visible text (titles, lede, prompts) before the pilot.
+- Use the agreed primary language: the narration source is `narration.<lang>.json`, the chapter loads `audio/<lang>/timings.js`, and `CHAPTER.language` matches (default `en`; it picks the audio folder). Set the same `<html lang>` in `index.html` and every chapter: the player and the contents page take their interface text from it (English, Russian, Chinese, Japanese and Arabic are built in, Arabic right to left as [engine.md](engine.md) describes; other languages fall back to English until a block is added to the engine's `TRANSLATIONS`). Take `voice` and `rate` from `style.json`, and translate the template's visible text (titles, lede, prompts) before the pilot.
- A chapter's minutes appear on its title screen (`CHAPTER.minutes`), its contents card and any series card, the same number in each: the length of its audio (the `dur`s in `timings.js`) plus about 15 s per question, rounded to whole minutes and never below 1.
- Each book has its own engine copy, kept in step by `engine.py` ([core/engine.md](engine.md)). The engine and the cover or series page take the progress key from the book's URL folder ([core/engine.md](engine.md#player)), so moving a book resets its readers' progress unless `--progress-key` is set in `lib/book.css`.
- A chapter returns to its book's index; the book opens directly at `/<book>/` and needs no parent index page. Every chapter but the last sets `CHAPTER.next` to the next one.
diff --git a/.claude/skills/papermorph/references/core/sound.md b/.claude/skills/papermorph/references/core/sound.md
index b0436f5..54fe739 100644
--- a/.claude/skills/papermorph/references/core/sound.md
+++ b/.claude/skills/papermorph/references/core/sound.md
@@ -29,6 +29,7 @@ Voices carry every book and everything else sits under them: in early cuts music
- **`tts.py`** (free): `uv run --with edge-tts SKILL/scripts/tts.py <narration.json> site/<book>/chNN/audio/<lang>` writes `<beat>.mp3` and `timings.js` (duration, marks, captions) and caches each finished beat beside the narration file: moving `[[marks]]` reuses the cache, and after a failure the same command resumes. At a few seconds a beat, a long chapter can outlast a tool's foreground time limit: run it in the background and wait for it before `lint.py`.
- `"engine": "edge"` (default, online) or `"kokoro"` (local, Apache 2.0, English word timings; voices such as `am_michael`, `af_heart`, `bm_george`; `uv run --python 3.12 --with kokoro …`), set at the top of the narration file with `voice` and `rate`. Keep one engine and voice per book (per character in a picture book).
- Edge's `...MultilingualNeural` voices guess the language sentence by sentence and read a short line such as "No zero, no fractions, no negatives." with a Spanish or Portuguese accent; a book in one language uses a one-language voice of that language.
+ - Arabic: Edge's Saudi voices `ar-SA-HamedNeural` and `ar-SA-ZariyahNeural` (`edge-tts --list-voices` lists other countries'). Their word timings match the text as written, diacritics (إِنَّ), Arabic-Indic digits (٥) and inline maths (x + 3 = 7) included, so `[[marks]]` work as in English, and `؟` ends a caption as `?` does. The service refuses an old `edge-tts` (HTTP 403 at the handshake); `uv run --with edge-tts` takes the current one.
- **`eleven.py`** (ElevenLabs v4 through OpenRouter, paid, an OpenRouter key): the voice the user chose for films. It writes the same clips and `timings.js`; the page cannot tell them apart.
- Voice and model come from `--voice` and `--model`, else from the narration file's `voice` and `model` (an ElevenLabs voice name such as `george`; the kits' files name an Edge voice).
- It prints the cost before paying (`--dry` stops there; about $0.07 a minute, quote it) and caches paid clips (a rerun costs nothing); `--only beat,beat` makes a fresh, paid take of those beats alone.
diff --git a/.claude/skills/papermorph/references/lessons/diagrams.md b/.claude/skills/papermorph/references/lessons/diagrams.md
index 88ad87c..6476b1c 100644
--- a/.claude/skills/papermorph/references/lessons/diagrams.md
+++ b/.claude/skills/papermorph/references/lessons/diagrams.md
@@ -3,6 +3,7 @@
For abstract and procedural ideas (the maths books, `site/elementary-algebra/` and `site/math-notebook/`). The picture explains through change: things are rearranged, split, balanced, counted and compared while the narration says why. The change is the argument, so each move must be one the idea allows.
- **One reading line.** A derivation or a procedure reads in one direction, each step under or beside the last, aligned on what stays the same (the `=` sign, the place values), so the eye never searches for the next step.
+- **Arabic books read the page from the right, and their maths from the left.** The stage keeps its left-to-right coordinates in every language ([engine.md](../core/engine.md)), and mathematics reads left to right as in Arabic school books: `3 + 4 = 7`, a number line growing to the right. What is ordered by reading rather than by mathematics starts at the right: a label sits to the right of what it names, a row of steps or pictures begins on the right, a table's first column is the right one. Look at a frame with `strip.py` and read it as an Arabic reader would.
- **Change the thing, don't replace it.** Tokens that combine move together and collapse into the result (`tokens`, `collapse`); a tile pair cancels where it stands; a dot hops along the number line. A fresh line of text is a weaker picture than the old one transforming.
- **Exact where it matters.** Number lines, grids, areas and graphs are to scale; illustrative pictures only need to be clear. Approximations are written as approximations (≈ 4.47…, not = 4.47).
- **Show the common mistake** where one exists (squaring the coefficient too), visibly crossed out, then the right way.
diff --git a/.claude/skills/papermorph/scripts/tts.py b/.claude/skills/papermorph/scripts/tts.py
index e22562f..0c8638a 100644
--- a/.claude/skills/papermorph/scripts/tts.py
+++ b/.claude/skills/papermorph/scripts/tts.py
@@ -176,7 +176,7 @@ def mark_times(clean, marks, words):
return out
-SENTENCE_END = re.compile(r"[.?!]\s+|[。!?]\s*")
+SENTENCE_END = re.compile(r"[.?!؟]\s+|[。!?]\s*") # ؟ is the Arabic question mark
ABBREV = re.compile(r"(?<![\w.])(?:Mr|Mrs|Ms|Dr|Prof|St|vs|approx|e\.g|i\.e|cf)\.$")
diff --git a/.github/scripts/check_tts_text.py b/.github/scripts/check_tts_text.py
new file mode 100644
index 0000000..ac3dcc9
--- /dev/null
+++ b/.github/scripts/check_tts_text.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+"""Captions and marks from narration text, without a voice: tts.py's text rules for each script it supports.
+
+ python3 .github/scripts/check_tts_text.py
+
+The spoken words a voice would return are written out by hand here, so the check needs no network and no audio.
+"""
+import importlib.util
+import sys
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[2]
+spec = importlib.util.spec_from_file_location("tts", ROOT / ".claude/skills/papermorph/scripts/tts.py")
+tts = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(tts)
+
+failures = []
+
+
+def check(name, got, want):
+ if got != want:
+ failures.append(f"{name}:\n got {got!r}\n want {want!r}")
+
+
+def words_at(clean, seconds):
+ """(time, word) pairs for the text's space-separated words, as a voice's word boundaries would give them."""
+ return list(zip(seconds, [w.strip(".?!؟،") for w in clean.split()]))
+
+
+# Arabic: a question ends with the Arabic question mark (؟), which must close its caption like "?" does.
+raw = "مساحة المستطيل تساوي الطول في العرض. ما مساحة [[q]]مستطيل طوله خمسة؟ الجواب [[a]]عشرون."
+clean, marks = tts.split_marks(raw)
+words = words_at(clean, [0.0, 0.5, 1.0, 1.4, 1.7, 2.0, 3.0, 3.4, 3.8, 4.2, 4.8, 5.6, 6.1])
+check("Arabic captions split at ؟", [text for _, text in tts.caption_cues(clean, words)],
+ ["مساحة المستطيل تساوي الطول في العرض.", "ما مساحة مستطيل طوله خمسة؟", "الجواب عشرون."])
+check("Arabic caption starts", [t for t, _ in tts.caption_cues(clean, words)], [0.0, 3.0, 5.6])
+check("Arabic marks land on their words", tts.mark_times(clean, marks, words), {"q": 3.8, "a": 6.1})
+
+# English stays as it was.
+clean, marks = tts.split_marks("One idea. Is it [[w]]true? Yes.")
+words = words_at(clean, [0.0, 0.4, 1.0, 1.2, 1.4, 2.0])
+check("English captions", [text for _, text in tts.caption_cues(clean, words)], ["One idea.", "Is it true?", "Yes."])
+
+if failures:
+ print("\n".join(failures))
+ sys.exit(1)
+print("tts text rules: ok")
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 1301f37..f77796a 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -16,6 +16,8 @@ jobs:
- uses: actions/checkout@v5
- name: Skill docs agree with its files
run: python3 .github/scripts/check_skill.py
+ - name: Narration captions and marks (no voice needed)
+ run: python3 .github/scripts/check_tts_text.py
- name: Python scripts (pyflakes errors, no unused-import noise)
run: pipx run ruff check --select F,E9 --ignore F401 --output-format concise .claude/skills/papermorph/scripts .github engine
diff --git a/engine/check_i18n.py b/engine/check_i18n.py
index c0e30a9..bd0323a 100644
--- a/engine/check_i18n.py
+++ b/engine/check_i18n.py
@@ -27,7 +27,8 @@ TEMPLATES = SKILL / "assets/templates"
TIMING = {"dur": 30, "marks": {"sub": 1, "note": 2, "w1": 3, "w2": 4}, "cues": []}
TIMINGS = "const TIMINGS = " + json.dumps({beat: TIMING for beat in ("intro", "idea", "q1", "wrap", "final1", "finish")})
# Page variants: (html lang, engine and book template from BASE_REF instead of the working tree).
-VARIANTS = {"base": ("en", True), "en": ("en", False), "ru": ("ru", False), "zh": ("zh", False), "ja": ("ja", False), "de": ("de", False)}
+VARIANTS = {"base": ("en", True), "en": ("en", False), "ru": ("ru", False), "zh": ("zh", False), "ja": ("ja", False), "de": ("de", False),
+ "ar": ("ar", False)}
def at_base_ref(path):
@@ -291,6 +292,76 @@ async def check_cjk(browser, errors):
print("PASS Chinese and Japanese lesson cover and book contents")
+async def check_arabic_lesson(browser, errors):
+ page = await open_lesson(browser, "ar", errors)
+ text = lambda selector: page.locator(selector).first.text_content()
+ style = lambda selector, prop: page.locator(selector).first.evaluate(f"e => getComputedStyle(e).{prop}")
+ # Text reads right to left; the drawing and the timeline keep their left-to-right geometry, so ← is still "back".
+ assert await page.evaluate("document.documentElement.dir") == "rtl"
+ assert await style("#stage", "direction") == "ltr"
+ assert await style("#bar", "direction") == "ltr"
+ assert await text("#coverK") == "الفصل 1"
+ assert "ابدأ الدرس" in await text("#cover .go")
+ assert await text("#coverMeta") == "نحو 8 دقائق، مع الصوت وأسئلة قصيرة."
+ assert await page.locator("#help h2").text_content() == "اختصارات لوحة المفاتيح"
+ # Arabic has one, two, few (3–10), many (11–99) and other (100+).
+ assert await page.evaluate("[1, 2, 3, 11, 100].map(n => translate('aboutMinutes', { n })).join('|')") == (
+ "نحو دقيقة، مع الصوت وأسئلة قصيرة.|نحو دقيقتين، مع الصوت وأسئلة قصيرة.|نحو 3 دقائق، مع الصوت وأسئلة قصيرة.|"
+ "نحو 11 دقيقة، مع الصوت وأسئلة قصيرة.|نحو 100 دقيقة، مع الصوت وأسئلة قصيرة.")
+ assert await page.evaluate("num(2.5) === '2.5' && num(-3) === '−3'"), "Arabic lessons write digits as 0–9 with a point"
+ assert await page.get_by_role("button", name="الترجمة النصية (C)", exact=True).count() == 1
+
+ # C on an Arabic layout types ؤ.
+ await page.locator("#cover").click()
+ await page.wait_for_function("P.started && P.audio.currentTime > .1")
+ before = await page.get_attribute("#bCC", "aria-pressed")
+ await press(page, "ؤ", "KeyC")
+ assert await page.get_attribute("#bCC", "aria-pressed") != before, "ؤ toggles captions"
+
+ # A question card reads from the right: its accent edge is on the right.
+ await page.evaluate("seek(2, false)")
+ await page.wait_for_timeout(200)
+ assert await text(".card .kicker") == "تحقّق سريع"
+ assert await style(".card", "direction") == "rtl"
+ assert await style(".card", "borderRightWidth") == "7px" and await style(".card", "borderLeftWidth") != "7px"
+ # Mathematics reads left to right inside Arabic text: "3 + 4 = [box]", the box after the expression, on its right.
+ assert await page.evaluate("""(() => { const m = document.querySelector('.card .bline svg.m').getBoundingClientRect(),
+ b = document.querySelector('.card .bline .box').getBoundingClientRect(); return b.left >= m.right - 1; })()"""), "equation flipped"
+ assert await style(".card svg.m", "direction") == "ltr"
+ # The bar's step label reads as the bar does: "3 / 6", not "6 / 3".
+ assert await style("#stepName", "direction") == "ltr"
+ await page.locator(".box").fill("6")
+ await page.locator(".box").press("Enter")
+ assert (await text(".card .fb")).startswith("ليس تماماً.")
+
+ await page.evaluate("seek(BEATS.length - 1, false)")
+ await page.wait_for_timeout(200)
+ card = await text(".card")
+ for line in ("اكتمل الفصل 1", "شاهد مرة أخرى", "كل الفصول"):
+ assert line in card, f"finish card lacks {line!r}"
+ print("PASS Arabic lesson: right-to-left text over a left-to-right stage, plurals, keys on an Arabic layout, questions")
+ await page.close()
+
+
+async def check_arabic_book(browser, errors):
+ page = await open_page(browser, "ar/", errors)
+ text = lambda selector: page.locator(selector).first.text_content()
+ assert await page.evaluate("document.documentElement.dir") == "rtl"
+ assert (await text("#cover .btn.go")).startswith("افتح الكتاب")
+ # Its arrow points the way the page reads: to the left.
+ assert await page.locator("#cover .btn.go svg").evaluate("e => getComputedStyle(e).transform") == "matrix(-1, 0, 0, 1, 0, 0)"
+ assert await text("#meta") == "فصل واحد · وحدة واحدة · مع الصوت", await text("#meta")
+ assert await text("#prog") == "فصل واحد"
+ assert await text(".unit h2 span") == "الوحدة 1"
+ assert await text(".ch small") == "8 دقائق"
+ await page.evaluate("localStorage.setItem('animebook:progress:/__i18n__/ar/', JSON.stringify({ done: [1], last: 1 }))")
+ await page.reload()
+ assert await text("#prog") == "اكتمل 1 من 1"
+ assert await text("#resume") == "تابع · الفصل 1"
+ print("PASS Arabic cover and contents: right to left, plurals, progress")
+ await page.close()
+
+
async def main():
errors = []
async with async_playwright() as playwright:
@@ -300,6 +371,8 @@ async def main():
await check_other_language(browser, errors)
await check_russian_book(browser, errors)
await check_cjk(browser, errors)
+ await check_arabic_lesson(browser, errors)
+ await check_arabic_book(browser, errors)
await browser.close()
assert not errors, errors
print("PASS no page errors, console errors or failed requests")
diff --git a/engine/check_tapwords.py b/engine/check_tapwords.py
index 30236a6..e23d3c8 100644
--- a/engine/check_tapwords.py
+++ b/engine/check_tapwords.py
@@ -195,9 +195,9 @@ async def main():
assert await js(word) == "box" and await js(count) == "You found them all!"
assert await js("PLAYED.length") == said, "the video's words played sound"
print("PASS video: P.tapDemo lists the clips and shows the words in turn, silently")
- missing = await js("['en', 'ru', 'zh', 'ja'].flatMap(l => ['wordsHeard', 'allWordsHeard'].filter(k => !TRANSLATIONS[l][k]).map(k => l + '.' + k))")
+ missing = await js("Object.keys(TRANSLATIONS).flatMap(l => ['wordsHeard', 'allWordsHeard'].filter(k => !TRANSLATIONS[l][k]).map(k => l + '.' + k))")
assert not missing, f"interface strings missing: {missing}"
- print("PASS interface strings in en, ru, zh and ja")
+ print("PASS interface strings in every interface language (" + ", ".join(await js("Object.keys(TRANSLATIONS)")) + ")")
assert not errors, errors
await browser.close()
diff --git a/engine/contents.css b/engine/contents.css
index d8f7f70..5c5a616 100644
--- a/engine/contents.css
+++ b/engine/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/engine/contents.js b/engine/contents.js
index 0bacf99..cb2629d 100644
--- a/engine/contents.js
+++ b/engine/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/engine/engine.css b/engine/engine.css
index bf42cc9..7083c22 100644
--- a/engine/engine.css
+++ b/engine/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/engine/engine.js b/engine/engine.js
index f36ec13..2177807 100644
--- a/engine/engine.js
+++ b/engine/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/engine/units.css b/engine/units.css
index e9c62cb..014ce88 100644
--- a/engine/units.css
+++ b/engine/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/elementary-algebra/lib/contents.css b/site/elementary-algebra/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/elementary-algebra/lib/contents.css
+++ b/site/elementary-algebra/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/elementary-algebra/lib/contents.js b/site/elementary-algebra/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/elementary-algebra/lib/contents.js
+++ b/site/elementary-algebra/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/elementary-algebra/lib/engine.css b/site/elementary-algebra/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/elementary-algebra/lib/engine.css
+++ b/site/elementary-algebra/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/elementary-algebra/lib/engine.js b/site/elementary-algebra/lib/engine.js
index f36ec13..2177807 100644
--- a/site/elementary-algebra/lib/engine.js
+++ b/site/elementary-algebra/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/elementary-algebra/lib/units.css b/site/elementary-algebra/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/elementary-algebra/lib/units.css
+++ b/site/elementary-algebra/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/joke-collection/lib/contents.css b/site/joke-collection/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/joke-collection/lib/contents.css
+++ b/site/joke-collection/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/joke-collection/lib/contents.js b/site/joke-collection/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/joke-collection/lib/contents.js
+++ b/site/joke-collection/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/joke-collection/lib/engine.css b/site/joke-collection/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/joke-collection/lib/engine.css
+++ b/site/joke-collection/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/joke-collection/lib/engine.js b/site/joke-collection/lib/engine.js
index f36ec13..2177807 100644
--- a/site/joke-collection/lib/engine.js
+++ b/site/joke-collection/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/joke-collection/lib/units.css b/site/joke-collection/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/joke-collection/lib/units.css
+++ b/site/joke-collection/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/linear-algebra/lib/contents.css b/site/linear-algebra/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/linear-algebra/lib/contents.css
+++ b/site/linear-algebra/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/linear-algebra/lib/contents.js b/site/linear-algebra/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/linear-algebra/lib/contents.js
+++ b/site/linear-algebra/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/linear-algebra/lib/engine.css b/site/linear-algebra/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/linear-algebra/lib/engine.css
+++ b/site/linear-algebra/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/linear-algebra/lib/engine.js b/site/linear-algebra/lib/engine.js
index f36ec13..2177807 100644
--- a/site/linear-algebra/lib/engine.js
+++ b/site/linear-algebra/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/linear-algebra/lib/units.css b/site/linear-algebra/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/linear-algebra/lib/units.css
+++ b/site/linear-algebra/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/little-red-riding-hood/lib/contents.css b/site/little-red-riding-hood/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/little-red-riding-hood/lib/contents.css
+++ b/site/little-red-riding-hood/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/little-red-riding-hood/lib/contents.js b/site/little-red-riding-hood/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/little-red-riding-hood/lib/contents.js
+++ b/site/little-red-riding-hood/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/little-red-riding-hood/lib/engine.css b/site/little-red-riding-hood/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/little-red-riding-hood/lib/engine.css
+++ b/site/little-red-riding-hood/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/little-red-riding-hood/lib/engine.js b/site/little-red-riding-hood/lib/engine.js
index f36ec13..2177807 100644
--- a/site/little-red-riding-hood/lib/engine.js
+++ b/site/little-red-riding-hood/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/little-red-riding-hood/lib/units.css b/site/little-red-riding-hood/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/little-red-riding-hood/lib/units.css
+++ b/site/little-red-riding-hood/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/madness-shorts/lib/contents.css b/site/madness-shorts/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/madness-shorts/lib/contents.css
+++ b/site/madness-shorts/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/madness-shorts/lib/contents.js b/site/madness-shorts/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/madness-shorts/lib/contents.js
+++ b/site/madness-shorts/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/madness-shorts/lib/engine.css b/site/madness-shorts/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/madness-shorts/lib/engine.css
+++ b/site/madness-shorts/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/madness-shorts/lib/engine.js b/site/madness-shorts/lib/engine.js
index f36ec13..2177807 100644
--- a/site/madness-shorts/lib/engine.js
+++ b/site/madness-shorts/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/madness-shorts/lib/units.css b/site/madness-shorts/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/madness-shorts/lib/units.css
+++ b/site/madness-shorts/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/madness/lib/contents.css b/site/madness/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/madness/lib/contents.css
+++ b/site/madness/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/madness/lib/contents.js b/site/madness/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/madness/lib/contents.js
+++ b/site/madness/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/madness/lib/engine.css b/site/madness/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/madness/lib/engine.css
+++ b/site/madness/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/madness/lib/engine.js b/site/madness/lib/engine.js
index f36ec13..2177807 100644
--- a/site/madness/lib/engine.js
+++ b/site/madness/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/madness/lib/units.css b/site/madness/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/madness/lib/units.css
+++ b/site/madness/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/math-notebook/lib/contents.css b/site/math-notebook/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/math-notebook/lib/contents.css
+++ b/site/math-notebook/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/math-notebook/lib/contents.js b/site/math-notebook/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/math-notebook/lib/contents.js
+++ b/site/math-notebook/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/math-notebook/lib/engine.css b/site/math-notebook/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/math-notebook/lib/engine.css
+++ b/site/math-notebook/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/math-notebook/lib/engine.js b/site/math-notebook/lib/engine.js
index f36ec13..2177807 100644
--- a/site/math-notebook/lib/engine.js
+++ b/site/math-notebook/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/math-notebook/lib/units.css b/site/math-notebook/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/math-notebook/lib/units.css
+++ b/site/math-notebook/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/pandemic-shorts/lib/contents.css b/site/pandemic-shorts/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/pandemic-shorts/lib/contents.css
+++ b/site/pandemic-shorts/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/pandemic-shorts/lib/contents.js b/site/pandemic-shorts/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/pandemic-shorts/lib/contents.js
+++ b/site/pandemic-shorts/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/pandemic-shorts/lib/engine.css b/site/pandemic-shorts/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/pandemic-shorts/lib/engine.css
+++ b/site/pandemic-shorts/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/pandemic-shorts/lib/engine.js b/site/pandemic-shorts/lib/engine.js
index f36ec13..2177807 100644
--- a/site/pandemic-shorts/lib/engine.js
+++ b/site/pandemic-shorts/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/pandemic-shorts/lib/units.css b/site/pandemic-shorts/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/pandemic-shorts/lib/units.css
+++ b/site/pandemic-shorts/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/pandemic/lib/contents.css b/site/pandemic/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/pandemic/lib/contents.css
+++ b/site/pandemic/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/pandemic/lib/contents.js b/site/pandemic/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/pandemic/lib/contents.js
+++ b/site/pandemic/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/pandemic/lib/engine.css b/site/pandemic/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/pandemic/lib/engine.css
+++ b/site/pandemic/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/pandemic/lib/engine.js b/site/pandemic/lib/engine.js
index f36ec13..2177807 100644
--- a/site/pandemic/lib/engine.js
+++ b/site/pandemic/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/pandemic/lib/units.css b/site/pandemic/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/pandemic/lib/units.css
+++ b/site/pandemic/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/physics-notebook/lib/contents.css b/site/physics-notebook/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/physics-notebook/lib/contents.css
+++ b/site/physics-notebook/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/physics-notebook/lib/contents.js b/site/physics-notebook/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/physics-notebook/lib/contents.js
+++ b/site/physics-notebook/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/physics-notebook/lib/engine.css b/site/physics-notebook/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/physics-notebook/lib/engine.css
+++ b/site/physics-notebook/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/physics-notebook/lib/engine.js b/site/physics-notebook/lib/engine.js
index f36ec13..2177807 100644
--- a/site/physics-notebook/lib/engine.js
+++ b/site/physics-notebook/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/physics-notebook/lib/units.css b/site/physics-notebook/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/physics-notebook/lib/units.css
+++ b/site/physics-notebook/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/proteus/lib/contents.css b/site/proteus/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/proteus/lib/contents.css
+++ b/site/proteus/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/proteus/lib/contents.js b/site/proteus/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/proteus/lib/contents.js
+++ b/site/proteus/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/proteus/lib/engine.css b/site/proteus/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/proteus/lib/engine.css
+++ b/site/proteus/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/proteus/lib/engine.js b/site/proteus/lib/engine.js
index f36ec13..2177807 100644
--- a/site/proteus/lib/engine.js
+++ b/site/proteus/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/proteus/lib/units.css b/site/proteus/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/proteus/lib/units.css
+++ b/site/proteus/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/science/lib/contents.css b/site/science/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/science/lib/contents.css
+++ b/site/science/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/science/lib/contents.js b/site/science/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/science/lib/contents.js
+++ b/site/science/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/science/lib/engine.css b/site/science/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/science/lib/engine.css
+++ b/site/science/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/science/lib/engine.js b/site/science/lib/engine.js
index f36ec13..2177807 100644
--- a/site/science/lib/engine.js
+++ b/site/science/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/science/lib/units.css b/site/science/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/science/lib/units.css
+++ b/site/science/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/shooting-an-elephant/lib/contents.css b/site/shooting-an-elephant/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/shooting-an-elephant/lib/contents.css
+++ b/site/shooting-an-elephant/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/shooting-an-elephant/lib/contents.js b/site/shooting-an-elephant/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/shooting-an-elephant/lib/contents.js
+++ b/site/shooting-an-elephant/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/shooting-an-elephant/lib/engine.css b/site/shooting-an-elephant/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/shooting-an-elephant/lib/engine.css
+++ b/site/shooting-an-elephant/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/shooting-an-elephant/lib/engine.js b/site/shooting-an-elephant/lib/engine.js
index f36ec13..2177807 100644
--- a/site/shooting-an-elephant/lib/engine.js
+++ b/site/shooting-an-elephant/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/shooting-an-elephant/lib/units.css b/site/shooting-an-elephant/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/shooting-an-elephant/lib/units.css
+++ b/site/shooting-an-elephant/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/site/three-little-pigs/lib/contents.css b/site/three-little-pigs/lib/contents.css
index d8f7f70..5c5a616 100644
--- a/site/three-little-pigs/lib/contents.css
+++ b/site/three-little-pigs/lib/contents.css
@@ -78,12 +78,12 @@ h1 i { color: var(--task); font-style: italic; }
.home .mascot { view-transition-name: guide; }
.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
.home strong i { color: var(--task); }
-.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog { margin-inline-start: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
.prog b { color: var(--good); font-weight: 600; }
main#contents { padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
- padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-inline-start: 6px solid var(--c);
text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
@@ -102,16 +102,16 @@ main#contents { padding-bottom: 80px; }
.refs-more a:hover { border-color: var(--dim); }
.refs-more b { font: 500 22px/1.2 var(--book); }
.refs-more span { color: var(--dim); font-size: 15px; }
-.refs-more i { margin-left: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
+.refs-more i { margin-inline-start: auto; font-style: normal; color: var(--quiz); font-weight: 600; font-size: 15px; }
#refpage { padding-bottom: 80px; }
.top .back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; text-decoration: none; color: var(--quiz); border-radius: 8px; }
-.top .rp-book { margin-left: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
+.top .rp-book { margin-inline-start: auto; font: 500 18px/1.2 var(--book); color: var(--dim); }
.top .rp-book i { color: var(--task); }
.refs { max-width: 1212px; margin: 32px auto 0; padding: 0 16px; }
.refs h1 { margin: 0 0 8px; font: 500 clamp(32px, 5vw, 44px)/1.1 var(--book); view-transition-name: none; }
.refs .lead { margin: 0 0 26px; max-width: 46em; color: var(--dim); }
.refs ol { margin: 0; padding: 0; list-style: none; color: var(--dim); font-size: 16px; line-height: 1.5; }
-.refs li { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
+.refs li { margin: 0 0 10px; padding-inline-start: 2em; text-indent: -2em; }
.refs a { color: var(--chalk); text-underline-offset: 3px; overflow-wrap: anywhere; }
.refs a:hover { color: var(--quiz); }
.stagger .top { animation: rise .6s var(--ease) backwards; }
@@ -135,3 +135,12 @@ main#contents { padding-bottom: 80px; }
*, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
.chalk span { opacity: .075; }
}
+/* Arabic (contents.js sets <html dir="rtl">): the layout follows through logical properties (border-inline-start, …).
+ Letters join, so no letter spacing; the faces are each system's own, no font file is loaded. A book's own :root
+ theme, after this file, still sets its faces (this rule has the same specificity as :root). */
+:root:where(:lang(ar)) {
+ --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
+ --book: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
+}
+:root:lang(ar) :is(.kicker, .meta, h1, .unit h2 .label) { letter-spacing: 0; }
+[dir="rtl"] .btn.go svg { transform: scaleX(-1); } /* "open" points the way the page reads */
diff --git a/site/three-little-pigs/lib/contents.js b/site/three-little-pigs/lib/contents.js
index 0bacf99..cb2629d 100644
--- a/site/three-little-pigs/lib/contents.js
+++ b/site/three-little-pigs/lib/contents.js
@@ -55,9 +55,28 @@ const Contents = (() => {
refsLead: '授業で引用したすべての著作です。リンクは著作の DOI または図書館の記録を新しいタブで開きます。信頼できるオンライン記録のない著作はリンクなしで載せています。',
refsCount: '授業で引用した著作 {n} 件', refsAllLinked: '、すべて出典へのリンクつき', refsSomeLinked: '、うち {n} 件は出典へのリンクつき',
},
+ // Arabic plurals: one 1, two 2, few 3–10, many 11–99, other 100+. Arrows point the way the page reads (right to left).
+ ar: {
+ open: 'افتح الكتاب', toCover: 'العودة إلى الغلاف', resume: 'تابع · الفصل {n}', unit: 'الوحدة {n}',
+ minutes: { one: 'دقيقة', two: 'دقيقتان', few: '{n} دقائق', many: '{n} دقيقة', other: '{n} دقيقة' },
+ meta: '{chapters}{samples} · {units} · مع الصوت',
+ metaChapters: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' },
+ metaUnits: { one: 'وحدة واحدة', two: 'وحدتان', few: '{n} وحدات', many: '{n} وحدة', other: '{n} وحدة' },
+ metaSamples: { one: ' + فصل تجريبي واحد', two: ' + فصلان تجريبيان', few: ' + {n} فصول تجريبية', many: ' + {n} فصلاً تجريبياً', other: ' + {n} فصل تجريبي' },
+ samples: 'فصول تجريبية بأسلوب آخر',
+ chapterCount: { one: 'فصل واحد', two: 'فصلان', few: '{n} فصول', many: '{n} فصلاً', other: '{n} فصل' }, finished: 'اكتمل {done} من {n}',
+ doneMark: '✓ مكتمل · ', lastMark: ' · آخر ما فُتح',
+ references: 'المراجع', viewAll: 'عرض الكل ←', backToContents: '→ المحتويات',
+ refsLead: 'كل الأعمال المستشهد بها في الدروس. يفتح كل رابط معرّف DOI للعمل أو سجله في المكتبة في علامة تبويب جديدة؛ والأعمال التي ليس لها سجل موثوق على الإنترنت مذكورة دون رابط.',
+ refsCount: { one: 'عمل واحد مستشهد به في الدروس', two: 'عملان مستشهد بهما في الدروس', few: '{n} أعمال مستشهد بها في الدروس',
+ many: '{n} عملاً مستشهداً به في الدروس', other: '{n} عمل مستشهد به في الدروس' },
+ refsAllLinked: '، وكلها مرتبطة بمصادرها', refsSomeLinked: '، منها {n} مرتبطة بمصادرها',
+ },
};
// the same lookup as translate() in engine.js (the two pages never load each other's file): keep them in step
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ // right-to-left interface languages, as RTL_LANGUAGES in engine.js: keep them in step
+ if (!document.documentElement.dir && ['ar'].includes(LANGUAGE)) document.documentElement.dir = 'rtl';
function translate(key, vars = {}) {
const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
let text = TRANSLATIONS[language][key] ?? key;
diff --git a/site/three-little-pigs/lib/engine.css b/site/three-little-pigs/lib/engine.css
index bf42cc9..7083c22 100644
--- a/site/three-little-pigs/lib/engine.css
+++ b/site/three-little-pigs/lib/engine.css
@@ -49,7 +49,7 @@ button[hidden] { display: none; }
.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }
/* Question cards inside the picture. */
-.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: color-mix(in srgb, var(--panel) 97%, transparent); border: 1.5px solid var(--edge); border-inline-start: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
.band .head { grid-area: head; align-self: end; }
@@ -73,7 +73,7 @@ button[hidden] { display: none; }
.fb:empty { display: none; }
.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
-.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.fb ul { margin: 6px 0 0; padding-inline-start: 22px; }
.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
.acts { display: flex; gap: 12px; align-items: center; }
.side .acts { margin-top: 16px; }
@@ -94,8 +94,8 @@ button[hidden] { display: none; }
.grid .mark { font-weight: 700; text-align: center; }
.grid .mark.good { color: var(--good); }
.grid .mark.bad { color: var(--bad); }
-.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
-.grid.text .why { padding-left: 0; }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-inline-start: 186px; }
+.grid.text .why { padding-inline-start: 0; }
.grid .why:empty { display: none; }
.hit { cursor: pointer; }
@@ -106,7 +106,7 @@ button[hidden] { display: none; }
/* Point and read (tapWords): hit boxes over the picture, the word beside a tapped thing, the counter and Continue.
A book can set --word-font for its early-reader letters. */
.tapw .ring { stroke-width: 5; }
-#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-left-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
+#ui > .card.word { pointer-events: none; padding: 2px 36px 10px; border-inline-start-width: 1.5px; border-radius: 30px; font: 600 96px/1.15 var(--word-font, var(--ui)); white-space: nowrap; animation: word-in .3s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes word-in { from { transform: scale(.6); opacity: 0; } }
.card.words .acts { margin: 0; gap: 18px; }
.card.words .count { font-size: 24px; font-weight: 600; color: var(--dim); }
@@ -160,12 +160,12 @@ button[hidden] { display: none; }
}
@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
-.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
+.sound-note { position: absolute; inset-inline-start: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.blanks .brow:last-child { border-bottom: 0; }
.blanks .bline { line-height: 64px; white-space: nowrap; }
-.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark { display: inline-block; margin-inline-start: 14px; font-weight: 700; }
.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
.blanks .mark.bad { color: var(--bad); }
.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
@@ -175,7 +175,7 @@ button[hidden] { display: none; }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
-kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-inline-start: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.opt kbd { margin: 0 .6em 0 0; }
.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
.keys kbd { margin: 0 .15em; }
@@ -188,7 +188,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.help-cols:has(> [hidden]) { grid-template-columns: 1fr; }
.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
-.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt { text-align: end; padding-inline-end: 18px; white-space: nowrap; }
.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
.help dd { margin: 0; color: var(--dim); }
.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }
@@ -222,15 +222,15 @@ svg.m { display: inline-block; overflow: visible; }
.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
-.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .acts { position: absolute; inset-inline-end: 70px; bottom: 48px; }
.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
/* a long label (a system of equations) widens the label column for every row instead of running off the card's left */
.screen .grid:not(.text) { display: grid; grid-template-columns: minmax(200px, max-content) minmax(0, 1fr) 40px; }
.screen .grid:not(.text) > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
-.screen .grid .why { padding-left: 216px; font-size: 20px; }
-.screen .grid.text .why { padding-left: 0; }
+.screen .grid .why { padding-inline-start: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-inline-start: 0; }
#ui > .screen.sort { pointer-events: none; }
.screen.sort > * { pointer-events: auto; }
.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
@@ -273,10 +273,10 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }
a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }
#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ui a.cite:hover { color: var(--quiz); }
-.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }
+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: start; }
.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }
.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }
-.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }
+.fin .srcs li { padding-inline-start: 2em; text-indent: -2em; margin: 0 0 6px; }
.fin .srcs a { color: var(--chalk); text-underline-offset: 3px; }
.fin .srcs a:hover { color: var(--quiz); }
.fin .srcs a:focus-visible { outline: 3px solid var(--task); outline-offset: 2px; }
@@ -295,3 +295,14 @@ a.btn { text-decoration: none; display: inline-block; }
/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */
:root[data-stage="portrait"] .step { width: 120px; } /* the 900-wide bar keeps room for the steps */
:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }
+/* Right-to-left interface text (engine.js sets <html dir="rtl"> for Arabic). Cards, captions, help and the cover read from
+ the right through the logical properties above (border-inline-start, inset-inline-end, …). The stage and the player bar
+ keep their left-to-right geometry, so a drawing's coordinates, the timeline and the ← → keys mean the same in every
+ language (the bar's step label reads "3 / 6 title" as the bar does). Mathematics reads left to right inside Arabic
+ text, as in Arabic school books: an expression (svg.m) and an answer line (.bline: "3 + 4 = [box] ✗") keep their order. */
+[dir="rtl"] :is(#stage, #bar, svg.m, .bline) { direction: ltr; }
+/* Arabic letters join: letter spacing breaks the words apart. The faces are each system's own Arabic UI and book faces;
+ no font file is loaded. A book's own lib/book.css :root still wins (these have no specificity). */
+:where(:root:lang(ar)) { --ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
+:root:lang(ar) :is(.cover-k, .fin .kicker, .fin .srcs h2) { letter-spacing: 0; }
+:root:lang(ar) .cover-t, :root:lang(ar) .fin .prompt { font-family: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif; }
diff --git a/site/three-little-pigs/lib/engine.js b/site/three-little-pigs/lib/engine.js
index f36ec13..2177807 100644
--- a/site/three-little-pigs/lib/engine.js
+++ b/site/three-little-pigs/lib/engine.js
@@ -161,6 +161,49 @@ const TRANSLATIONS = {
watchAgain: 'もう一度見る', nextChapter: '次の章へ',
wordsHeard: '{k} / {n}', allWordsHeard: 'ぜんぶ見つけたね!',
},
+ // Arabic plurals (Intl.PluralRules 'ar'): one 1, two 2, few 3–10, many 11–99, other 100+ (zero falls back to other).
+ // The timeline keeps its left-to-right geometry in Arabic (see RTL below), so ← stays "previous step".
+ ar: {
+ decimalSign: '.', stageLabel: 'رسوم الدرس المتحركة', stageLabelTitled: 'رسوم الدرس المتحركة: {title}',
+ shortcuts: 'اختصارات لوحة المفاتيح', lesson: 'الدرس', questions: 'الأسئلة',
+ helpPlay: 'تشغيل أو إيقاف مؤقت', helpStep: 'الخطوة السابقة أو التالية', helpStepInQuestion: 'تغيير الخطوة أثناء السؤال', helpRestart: 'البدء من جديد',
+ helpCaptions: 'إظهار الترجمة النصية أو إخفاؤها', helpSpeed: 'أبطأ أو أسرع', helpFullScreen: 'ملء الشاشة', helpList: 'عرض هذه القائمة',
+ helpChoose: 'اختيار إجابة أو دائرة', helpTrueFalse: 'صواب أو خطأ', helpRows: 'التنقل بين الصفوف',
+ helpNumberLine: 'التحرك على خط الأعداد، أو اختيار عدد لتصنيفه', helpEnter: 'تحقّق، ثم تابع',
+ helpShowAnswer: 'عرض الإجابة', helpLeaveBox: 'الخروج من خانة الإجابة', helpClose: 'اضغط {key} للإغلاق.',
+ paused: 'متوقف مؤقتاً. اضغط مفتاح المسافة أو انقر للمتابعة.',
+ soundFailed: 'تعذّر تشغيل الصوت. يستمر الدرس بالنص المعروض على الشاشة.',
+ startLesson: 'ابدأ الدرس', startFilm: 'تشغيل',
+ aboutMinutesFilm: { one: 'نحو دقيقة، مع الصوت.', two: 'نحو دقيقتين، مع الصوت.', few: 'نحو {n} دقائق، مع الصوت.',
+ many: 'نحو {n} دقيقة، مع الصوت.', other: 'نحو {n} دقيقة، مع الصوت.' },
+ coverKeys: 'اضغط {space} للبدء، و{help} للاختصارات.', spaceKey: 'المسافة',
+ chapterNumber: 'الفصل {n}',
+ aboutMinutes: { one: 'نحو دقيقة، مع الصوت وأسئلة قصيرة.', two: 'نحو دقيقتين، مع الصوت وأسئلة قصيرة.',
+ few: 'نحو {n} دقائق، مع الصوت وأسئلة قصيرة.', many: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.', other: 'نحو {n} دقيقة، مع الصوت وأسئلة قصيرة.' },
+ allChapters: 'كل الفصول', playLabel: 'تشغيل أو إيقاف مؤقت (المسافة)', backLabel: 'الخطوة السابقة (السهم الأيسر)', restartLabel: 'إعادة الدرس',
+ checksInLesson: 'الأسئلة القصيرة والتمارين موجودة في الدرس التفاعلي.',
+ volumeLabel: 'ضبط مستوى الصوت', volumeTitle: 'مستوى الصوت (0 = صامت)', volumeSlider: 'مستوى الصوت',
+ helpLabel: 'اختصارات لوحة المفاتيح (?)', speedLabel: 'سرعة التشغيل (< و >)', captionsLabel: 'الترجمة النصية (C)', fullScreenLabel: 'ملء الشاشة', goToStep: 'الانتقال إلى الخطوة {n}: {title}',
+ quickCheck: 'تحقّق سريع', countOf: 'السؤال {k} من {n}', check: 'تحقّق', showAnswer: 'أظهر الإجابة', nextQuestion: 'السؤال التالي', continue: 'تابع',
+ correct: 'صحيح. ', notQuite: 'ليس تماماً. ', answerPrefix: 'الإجابة: ', keysPrefix: 'المفاتيح: ',
+ hintMove: ' للتحرك، ', hintChoose: ' للاختيار', hintChooseOrClickGrid: ' للاختيار، أو انقر على الشبكة', hintMoveAlongLine: ' للتحرك على الخط، ',
+ hintChooseOrClick: ' للاختيار، أو انقر', hintRow: ' للصف، ', hintTypeFraction: 'اكتب أعداداً مثل 3/4 أو −2 1/4، ', hintTypeNumber: 'اكتب العدد، ',
+ hintTypeDecimal: 'اكتب العدد، ', hintNextBox: ' للخانة التالية، ', hintCheck: ' للتحقق، ', hintLeaveBox: ' للخروج من الخانة',
+ hintPickNumber: ' لاختيار عدد، ', hintPickRing: ' لاختيار دائرته',
+ rowsRight: '{r} من {n} صحيحة. صحّح الصفوف المعلّمة بـ ✗ ثم تحقّق مرة أخرى.',
+ choicesShown: 'حُدّدت الخيارات الصحيحة الآن.', numbersShown: 'كُتبت الأعداد الصحيحة.',
+ notPlacedYet: 'لم يوضع {x} بعد.',
+ realRingIsEmpty: '{x}: كل عدد حقيقي إما نسبي أو غير نسبي، لذلك لا توجد أعداد خاصة بهذه المنطقة.',
+ ringsRight: '{r} من {n} في الدائرة الصحيحة.', ringsShown: 'كل عدد الآن في أصغر دائرة تحتويه.',
+ chipPlaced: '{x}، موضوع في {ring}', chipNotPlaced: '{x}، لم يوضع', pointLabel: 'النقطة {v}', answerBox: 'الإجابة',
+ stepsLeftOfZero: { one: 'خطوة واحدة يسار 0', two: 'خطوتان يسار 0', few: '{n} خطوات يسار 0', many: '{n} خطوة يسار 0', other: '{n} خطوة يسار 0' },
+ natural: 'الطبيعية', whole: 'الكلية', integers: 'الصحيحة', rational: 'النسبية', irrational: 'غير النسبية', real: 'الحقيقية', integerColumn: 'صحيح',
+ trueLabel: 'صواب', falseLabel: 'خطأ',
+ chapterComplete: 'اكتمل الفصل {n}', quickChecks: 'الأسئلة القصيرة', chapterPractice: 'تمارين الفصل', sources: 'مصادر هذا الفصل', opensSource: '{label}، يفتح المصدر في علامة تبويب جديدة',
+ firstTryScore: '{name}: {r} من {t} صحيحة من المحاولة الأولى.', notAttempted: '{name}: لم تُحاوَل.',
+ watchAgain: 'شاهد مرة أخرى', nextChapter: 'الفصل التالي',
+ wordsHeard: '{k} / {n}', allWordsHeard: 'وجدتها كلها!',
+ },
};
// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.
const PORTRAIT = document.documentElement.dataset.stage === 'portrait';
@@ -168,6 +211,11 @@ const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;
document.documentElement.style.setProperty('--sw', SW + 'px');
document.documentElement.style.setProperty('--sh', SH + 'px');
const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+// Interface languages written right to left. Their text reads from the right while the stage and the timeline keep
+// their left-to-right geometry (engine.css), so drawings, seeking and the arrow keys mean the same in every language.
+// A page that sets <html dir> itself keeps it. contents.js has the same list: keep the two in step.
+const RTL_LANGUAGES = ['ar'];
+if (!document.documentElement.dir && RTL_LANGUAGES.includes(LANGUAGE)) document.documentElement.dir = 'rtl';
const pluralRules = {};
// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.
// contents.js has its own copy for the contents page: keep the two in step.
@@ -266,11 +314,12 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
/* ---------- drawing helpers ---------- */
const NS = 'http://www.w3.org/2000/svg';
-const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
// --progress-key for the localStorage key the cover and chapters share.
const BOOK = getComputedStyle(document.documentElement);
const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+// The interface face, for measuring text on the canvas: engine.css's --ui (an Arabic page has its own), or a book's.
+const UI = bookSetting('--ui').replace(/,\s+/g, ',') || '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
// The board and ink colours come from the palette in engine.css, which lib/book.css may redefine (a light board):
// the picture, the cards and the player bar then agree. The six hues are the chapters' meanings, set in JS.
const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
diff --git a/site/three-little-pigs/lib/units.css b/site/three-little-pigs/lib/units.css
index e9c62cb..014ce88 100644
--- a/site/three-little-pigs/lib/units.css
+++ b/site/three-little-pigs/lib/units.css
@@ -6,7 +6,7 @@
.unit .grid { position: relative; }
.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
-.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+.unit-art { position: absolute; top: 20px; inset-inline-end: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
.unit-art .a { color: var(--chalk); opacity: .55; }
@@ -66,7 +66,7 @@
.unit-art { will-change: transform; contain: layout style; }
.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
@media (max-width: 560px) {
- .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit-art { width: calc(100% - 32px); inset-inline-end: 16px; opacity: .32; }
.unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {