Skip to content

feat: native i18n locale support for screenshots#95

Merged
omachala merged 5 commits into
mainfrom
feat/locale-screenshots
Apr 11, 2026
Merged

feat: native i18n locale support for screenshots#95
omachala merged 5 commits into
mainfrom
feat/locale-screenshots

Conversation

@omachala

Copy link
Copy Markdown
Owner

Summary

Closes #94 — adds native locale/i18n support so users can generate screenshots for multiple languages without duplicating screenshot definitions.

  • New locales config option: locales: ['en', 'de', 'fr']
  • {locale} URL placeholder: replaced per locale in url field for path-based routing
  • Browser locale setting: Playwright context locale + Accept-Language header set per locale
  • Output structure: multiple locales → heroshots/en/home.png, heroshots/de/home.png; single locale → flat heroshots/home.png (fully backwards compatible)
  • Parallel + sequential: both capture paths support locales; each locale gets its own browser launch (Playwright context-level requirement)

Changes

  • src/schema.tslocales?: string[] field in configSchema
  • src/browser/types.ts + launchBrowser.tslocale option passed to Playwright context
  • src/sync/types.tslocale? + localeUrl? on CaptureVariant
  • src/sync/sync.ts — iterates (locale, colorScheme) pairs in sequential path
  • src/sync/schemeCapture.ts — passes locale to browser launch + resolves {locale} URLs
  • src/sync/parallelCapture.tsCaptureJob extended with locale fields; groups by locale for separate browser instances
  • src/sync/configHelpers.tscalculateTotalCaptures accounts for locale count
  • src/sync/results.tsbuildVariantSuffix includes locale prefix
  • src/utils/localeUrl.ts (new) — applyLocale(url, locale) utility
  • src/utils/screenshotPath.ts — prepends locale as directory when multiple locales configured
  • docs/docs/config-reference.md — full documentation for locales option

Test plan

  • Unit tests: pnpm test:run — all 487 tests pass
  • CLI e2e tests: src/tests/cli/locale.test.ts — 3 tests verifying locale subdirectory output
  • Single locale config → flat output (backwards compat)
  • Multi-locale config → {locale}/ subdirectories created
  • {locale} URL placeholder replaced per locale
  • CI passes before merging

Ondrej Machala added 2 commits April 11, 2026 20:01
Add `locales` config option to generate screenshots for multiple languages
without duplicating screenshot definitions. Use `{locale}` in URLs for
path-based routing. Browser locale and Accept-Language headers are set
per locale. Multiple locales output to `{locale}/` subdirectories;
single locale preserves existing flat structure (backwards compatible).
Shorten locales describe text to fit on a single line and remove
intermediate variables in parallelCapture.ts to bring both files
within the 200-line limit.
@changeset-bot

changeset-bot Bot commented Apr 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a5fc76c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Apr 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Ondrej Machala added 2 commits April 11, 2026 20:33
The generator now owns the Locale Screenshots section in config-reference.md
via a suffix constant, preventing the CI docs-freshness check from failing.
Also regenerates config-reference.md to match current generator output.
@omachala omachala enabled auto-merge (squash) April 11, 2026 20:40
@sonarqubecloud

Copy link
Copy Markdown

@omachala omachala merged commit f079600 into main Apr 11, 2026
14 of 15 checks passed
@omachala omachala deleted the feat/locale-screenshots branch April 11, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question about Localization support

1 participant