Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
node-version-file: .nvmrc
cache: npm
- run: npm ci
# The app in Russian, Serbian, Spanish and German, with the runner's Google Chrome.
# The app in Spanish, German, Russian and Serbian, with the runner's Google Chrome.
- run: npm run site:shots
env:
CHROME_PATH: /usr/bin/google-chrome
Expand Down
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ You need Node 22 or later (see `.nvmrc`). Use npm.
| `npm run preview` | Serve the production build |
| `docker build -t thanos-automa .` | Build the production image (nginx on port 8080); `docker compose up -d` runs the published one |
| `npm run screenshots` | Build, then capture the guide screenshots into `docs/guide/screenshots/` (needs Google Chrome; fails unless every PNG is 780×1688). Options after `--`: `--lang ru`, `--only 04,06`, `--out <dir>`, `--width 360` |
| `npm run site:shots` | Build, then capture the app in Russian, Serbian, Spanish and German for the landing page into `.screenshots/` (not committed; needs Google Chrome) |
| `npm run site:shots` | Build, then capture the app in Spanish, German, Russian and Serbian for the landing page into `.screenshots/` (not committed; needs Google Chrome) |
| `npm run site` | Render the landing page in five languages into `_site/` from `site/index.html` and `site/locales/*.json`, with the screenshots, fonts and icons. `npx vite preview --outDir _site` serves it |
| `npm run reference` | Download the reference PDFs (rulebook, automa) into `docs/reference/` from the `reference-docs` release |
| `npm run sim` | Simulate Thanos playing alone on the engine and print Markdown tables per settings preset (see [`docs/automa.md`](docs/automa.md#simulation)). Options after `--`: `--runs N` (default 10,000 games), `--seed S` (default 1); the same options print the same tables |
Expand All @@ -104,13 +104,13 @@ src/
components/ comic kit: Token, Button, Caption, chips, stone tiles, sheets, dialog, toasts, Versus HUD, dock, cards
game/ game screen: steps (reveal, take, recruit, table, phase change, game over) and dock sheets
home/ home, setup and rulings
i18n/ translations: locales/{en,ru,sr,es,de}.json (ICU; Serbian in Cyrillic), loader, t(), detection
i18n/ translations: locales/{en,es,de,ru,sr}.json (ICU; Serbian in Cyrillic), loader, t(), detection
pwa/ install card and iOS install sheet, splash, update and offline toasts
state/ persistence, useGame, prefs, wake lock
test/ shared test setup, and helpers that tick the setup and finish a turn (play.ts)
e2e/ Playwright smoke test on a phone viewport, against the production build (npm run e2e)
public/ static files: favicon, PWA icons (renders of scripts/gen-logo.mjs)
site/ landing page for GitHub Pages: an HTML template, CSS and locales/{en,ru,sr,es,de}.json, rendered by scripts/build-site.mjs
site/ landing page for GitHub Pages: an HTML template, CSS and locales/{en,es,de,ru,sr}.json, rendered by scripts/build-site.mjs
scripts/ repo tooling (logo/icon generator, guide screenshots, landing page build, difficulty simulator)
docs/ rules, automa spec, design, user guide with screenshots, reference PDFs
```
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ stay on the table. The app replaces the automa deck, the token placement board a
bookkeeping.

**[Project page](https://thanos.silachev.com/)**: a short tour with
screenshots, in English, [Русский](https://thanos.silachev.com/ru/),
[Српски](https://thanos.silachev.com/sr/),
[Español](https://thanos.silachev.com/es/) and
[Deutsch](https://thanos.silachev.com/de/).
screenshots, in English, [Español](https://thanos.silachev.com/es/),
[Deutsch](https://thanos.silachev.com/de/),
[Русский](https://thanos.silachev.com/ru/) and
[Српски](https://thanos.silachev.com/sr/).

> **Status:** in development. Work is planned in
> [issues](https://github.com/asilachev/splendor-marvel-automa/issues) and
Expand Down Expand Up @@ -43,7 +43,7 @@ screenshots, in English, [Русский](https://thanos.silachev.com/ru/),
and per difficulty.
- **Lets you skip logging your cards:** tick "I completed the Gauntlet" in the round you do instead.
- **Plays the PDF's hard variant:** Thanos also claims the Locations, and you don't.
- **Speaks five languages:** English, Русский, Српски, Español and Deutsch. It follows your phone's
- **Speaks five languages:** English, Español, Deutsch, Русский and Српски. It follows your phone's
language, and the globe button on Home switches it.
- **Needs no card data.** When a card is recruited you tap its colour, points and Avengers tags. There
is no card database and no game art.
Expand Down
13 changes: 7 additions & 6 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ still called Thanos (owner's decision).
## Landing page (#61, #66, #69)

`site/` is a static page on GitHub Pages, in the app's five languages:
https://thanos.silachev.com/ (English), then `ru/`, `sr/`, `es/` and `de/`.
https://thanos.silachev.com/ (English), then `es/`, `de/`, `ru/` and `sr/`.

- **Domain:** a GitHub Pages custom domain (a CNAME to `asilachev.github.io`, HTTPS enforced);
the old `asilachev.github.io/splendor-marvel-automa/` address redirects to it. The owner's copy of
Expand Down Expand Up @@ -262,14 +262,15 @@ Movement only when it means something, and then short and smooth.

## Languages (#54)

- **Languages:** English, Russian, Serbian (Cyrillic script, #57), Spanish and German. The browser's language
is used on first launch. The picker is the globe button at the top of Home and the Language row in
the Menu, and the choice is saved in prefs. `<html lang>` follows it, so screen readers and
hyphenation use the right language.
- **Languages:** English, Spanish, German, Russian and Serbian (Cyrillic script, #57). The app's
selector and the landing page list them in this order, the owner's choice (#103). The browser's
language is used on first launch. The picker is the globe button at the top of Home and the
Language row in the Menu, and the choice is saved in prefs. `<html lang>` follows it, so screen
readers and hyphenation use the right language.
- **A language in the link (#85):** `?lang=ru` picks Russian and saves it, as if picked in the app;
the address bar then drops the parameter. The landing page's "Open the app" uses it. Unsupported
values are ignored. Without a saved choice the app keeps following the browser's language.
- **Translation files:** `src/ui/i18n/locales/{en,ru,sr,es,de}.json`, one per language, in ICU
- **Translation files:** `src/ui/i18n/locales/{en,es,de,ru,sr}.json`, one per language, in ICU
message syntax: `{round}`, `select` and `plural` with `#` (#58). English is bundled as the
fallback, and each other file loads only when its language is chosen, as its own chunk precached
for offline use. Code calls `t('home.continue', { round })` with keys typed from `en.json`. Tests
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keeps his tokens and cards in order, and checks the Infinity Gauntlet at the end
You need the physical game and a phone. The app has no card data. When someone recruits a card, you
tap its colour, points and Avengers tags.

The app speaks English, Русский, Српски, Español and Deutsch. It starts in your phone's language;
The app speaks English, Español, Deutsch, Русский and Српски. It starts in your phone's language;
change it with the globe button at the top of the home screen, or under **Menu → Language**.

**Contents**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"format:check": "prettier --check .",
"screenshots": "vite build && node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/screenshots.mjs",
"site": "node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/build-site.mjs",
"site:shots": "vite build && node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/screenshots.mjs --lang ru,sr,es,de --only 02,04,05,06,07,08,09,10,11,12,14,15",
"site:shots": "vite build && node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/screenshots.mjs --lang es,de,ru,sr --only 02,04,05,06,07,08,09,10,11,12,14,15",
"sim": "node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/sim.ts",
"test": "vitest run",
"test:watch": "vitest",
Expand Down
8 changes: 4 additions & 4 deletions scripts/build-site.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Assembles the GitHub Pages landing page into _site/, once per language (#61, #69):
//
// _site/index.html English, from the template site/index.html and site/locales/en.json
// _site/{ru,sr,es,de}/ the other languages
// _site/{es,de,ru,sr}/ the other languages
// _site/screenshots/<lang>/ the app in that language: English from docs/guide/screenshots,
// the others from .screenshots/<lang> (npm run site:shots)
//
Expand All @@ -19,13 +19,13 @@ const out = `${root}_site/`
const SITE_URL = 'https://thanos.silachev.com/'
const STORAGE_KEY = 'thanos-site:lang'

/** The app's languages, in the app's order; English lives at the root. */
/** The app's languages, in the app's order (EN, ES, DE, RU, SR, #103); English lives at the root. */
const LANGS = [
{ code: 'en', name: 'English', tag: 'en', locale: 'en_GB' },
{ code: 'ru', name: 'Русский', tag: 'ru', locale: 'ru_RU' },
{ code: 'sr', name: 'Српски', tag: 'sr-Cyrl', locale: 'sr_RS' },
{ code: 'es', name: 'Español', tag: 'es', locale: 'es_ES' },
{ code: 'de', name: 'Deutsch', tag: 'de', locale: 'de_DE' },
{ code: 'ru', name: 'Русский', tag: 'ru', locale: 'ru_RU' },
{ code: 'sr', name: 'Српски', tag: 'sr-Cyrl', locale: 'sr_RS' },
]
const dirOf = (code) => (code === 'en' ? '' : `${code}/`)

Expand Down
4 changes: 2 additions & 2 deletions scripts/screenshots.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// use another Chromium). Game states come from the engine with fixed seeds, so reruns match.
//
// Options, e.g. `npm run screenshots -- --lang ru,de --only 04,06`:
// --lang ru,sr,es,de the app's languages (default en); texts and buttons come from their files
// --lang es,de,ru,sr the app's languages (default en); texts and buttons come from their files
// --only 04,06-recruit shots whose names start with these
// --out <dir> where to write, with a folder per language when there are several
// (default docs/guide/screenshots for English, .screenshots/<lang> otherwise)
Expand All @@ -32,7 +32,7 @@ const { values: opt } = parseArgs({
})
const LANGS = opt.lang.split(',').map((lang) => lang.trim())
/** BCP 47 tags, as in LANGS in src/ui/i18n/index.ts. */
const TAGS = { en: 'en-GB', ru: 'ru', sr: 'sr-Cyrl', es: 'es', de: 'de' }
const TAGS = { en: 'en-GB', es: 'es', de: 'de', ru: 'ru', sr: 'sr-Cyrl' }
for (const lang of LANGS) if (!(lang in TAGS)) throw new Error(`Unknown language ${lang}`)
/** English goes to the guide's folder unless --out says otherwise. */
const isGuide = (lang) => !opt.out && lang === 'en'
Expand Down
7 changes: 7 additions & 0 deletions src/ui/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,13 @@ describe('languages (#54, #58)', () => {
expect(document.documentElement.lang).toBe('en')
await user.click(screen.getByRole('button', { name: 'Language: English' }))
const sheet = screen.getByRole('dialog', { name: 'LANGUAGE' })
// In the owner's order (#103).
const picker = within(sheet).getByRole('group', { name: 'Language' })
expect(
within(picker)
.getAllByRole('button')
.map((b) => b.textContent?.slice(0, 2)),
).toEqual(['EN', 'ES', 'DE', 'RU', 'SR'])
await user.click(within(sheet).getByRole('button', { name: /^DE/ }))
expect(screen.queryByRole('dialog')).toBeNull()
expect(await screen.findByRole('button', { name: 'DEIN ERSTES SPIEL' })).toBeInTheDocument()
Expand Down
8 changes: 6 additions & 2 deletions src/ui/i18n/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import ru from './locales/ru.json'
import sr from './locales/sr.json'

/** The language files, typed as English: a missing key fails the typecheck here too. */
const FILES: Record<Lang, Catalog> = { en, ru, sr, es, de }
const FILES: Record<Lang, Catalog> = { en, es, de, ru, sr }
const T = Object.fromEntries(
(Object.keys(FILES) as Lang[]).map((l) => [l, createTranslator(l, FILES[l])]),
) as Record<Lang, ReturnType<typeof createTranslator>>
Expand Down Expand Up @@ -63,8 +63,12 @@ describe('language files (#54, #58)', () => {
expect(detectLang(['fr', 'it'])).toBe('en')
})

it('lists the languages as EN, ES, DE, RU, SR (#103)', () => {
expect(LANGS.map((l) => l.code)).toEqual(['en', 'es', 'de', 'ru', 'sr'])
})

it('names every language in itself', () => {
expect(LANGS.map((l) => l.name)).toEqual(['English', 'Русский', 'Српски', 'Español', 'Deutsch'])
expect(LANGS.map((l) => l.name)).toEqual(['English', 'Español', 'Deutsch', 'Русский', 'Српски'])
expect(LANGS.find((l) => l.code === 'sr')?.tag).toBe('sr-Cyrl')
})

Expand Down
11 changes: 6 additions & 5 deletions src/ui/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { typeset, typesetAll } from './typography.ts'
*/

/** The app's languages. Serbian is written in Cyrillic, which the Bangers font covers (#57). */
export type Lang = 'en' | 'ru' | 'sr' | 'es' | 'de'
export type Lang = 'en' | 'es' | 'de' | 'ru' | 'sr'

/** The languages in the order the selector lists them, the owner's: EN, ES, DE, RU, SR (#103). */
export const LANGS: readonly {
readonly code: Lang
/** The language's own name, for the picker. */
Expand All @@ -20,20 +21,20 @@ export const LANGS: readonly {
readonly tag: string
}[] = [
{ code: 'en', name: 'English', tag: 'en' },
{ code: 'ru', name: 'Русский', tag: 'ru' },
{ code: 'sr', name: 'Српски', tag: 'sr-Cyrl' },
{ code: 'es', name: 'Español', tag: 'es' },
{ code: 'de', name: 'Deutsch', tag: 'de' },
{ code: 'ru', name: 'Русский', tag: 'ru' },
{ code: 'sr', name: 'Српски', tag: 'sr-Cyrl' },
]

export type Catalog = typeof en

/** One file per language, connected on demand. Each must have every key English has. */
const LOADERS: Readonly<Record<Exclude<Lang, 'en'>, () => Promise<{ default: Catalog }>>> = {
ru: () => import('./locales/ru.json'),
sr: () => import('./locales/sr.json'),
es: () => import('./locales/es.json'),
de: () => import('./locales/de.json'),
ru: () => import('./locales/ru.json'),
sr: () => import('./locales/sr.json'),
}

const loaded = new Map<Lang, Catalog>([['en', en]])
Expand Down
6 changes: 4 additions & 2 deletions src/ui/i18n/locales/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ Every text in the app lives here, in one file per language:
| File | Language |
| --- | --- |
| `en.json` | English: the source, bundled with the app, and the fallback for missing texts |
| `ru.json` | Русский |
| `sr.json` | Српски (Cyrillic script) |
| `es.json` | Español |
| `de.json` | Deutsch |
| `ru.json` | Русский |
| `sr.json` | Српски (Cyrillic script) |

The app lists them in this order: EN, ES, DE, RU, SR (#103).

The app loads only the file for the chosen language, so each file is one self-contained translation.

Expand Down
Loading