Skip to content

feat(widget): German localization (data-lang="de") - #6

Open
stigdreyer wants to merge 1 commit into
Abla25:mainfrom
stigdreyer:feat/widget-german-locale
Open

stigdreyer wants to merge 1 commit into
Abla25:mainfrom
stigdreyer:feat/widget-german-locale

Conversation

@stigdreyer

Copy link
Copy Markdown

Summary

Adds German as a third built-in widget language alongside English and Italian.

  • de dictionary in packages/widget/src/widget.js covering every key of
    the English dictionary (comments, replies, reactions, polls, relative
    timestamps). It uses the formal register ("Sie"), the usual default for
    German website UI.
  • Auto-detection generalized: a small SUPPORTED_LANGS list, matched on the
    primary subtag of navigator.language (so de-DE, de-AT, de-CH all resolve
    to German). Italian detection behaves as before; everything else still
    falls back to English. Adding a future locale is now just a dictionary entry
    plus one list item.
  • Admin embed builder: "Deutsch" option in the language selector.
  • Integrations: lang type/docs updated (en | it | de | auto).
  • Changelog entry under Unreleased.
  • static-content.ts regenerated via npm run build, as CONTRIBUTING.md asks.

No runtime/server changes and no new dependencies. The widget's security
invariants (textContent-only rendering, no cookies, no external requests) are
untouched.

Tests

New tests/security/widget-i18n.test.ts (7 tests):

  • data-lang="de" renders German copy
  • auto-detects German from de-AT, still detects Italian from it-IT
  • unsupported language (fr-FR) falls back to English
  • data-text overrides still win over the German dictionary
  • key parity: it and de must define exactly the English keys, so a
    future key added only to en fails CI instead of silently showing English
    or the raw key name. I checked it fails when a German key is removed.

Local results:

  • npx vitest run: 36 files passed, 1 skipped; 292 tests passed, 2 skipped
  • npm run typecheck: clean
  • npm run build:site && npm run check:size: all budgets pass

Context

We're integrating StaticLayer on a German-language memorial/history site and
had been passing every string through data-text. Upstreaming the locale lets
other German-speaking sites use it directly, and means new UI strings arrive
translated instead of falling back to English.

🤖 Generated with Claude Code

Add a full German dictionary for the widget (comments, reactions, polls)
and generalize auto-detection to a SUPPORTED_LANGS list matched on the
primary language subtag, so de-DE/de-AT/de-CH resolve to German. English
remains the fallback; data-text overrides still take precedence.

Also: 'Deutsch' option in the admin embed builder, lang type/docs in
integrations, and widget-i18n tests incl. a key-parity check across
locales.

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

This branch has not been deployed

No deployments
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.

1 participant