Skip to content

feat(widget): auto-detect locale from browser, ship FR/ES/DE presets - #77

Merged
Wifsimster merged 1 commit into
mainfrom
claude/fix-koe-locale-language-CGCDr
May 8, 2026
Merged

feat(widget): auto-detect locale from browser, ship FR/ES/DE presets#77
Wifsimster merged 1 commit into
mainfrom
claude/fix-koe-locale-language-CGCDr

Conversation

@Wifsimster

Copy link
Copy Markdown
Owner

Summary

The widget had a WidgetLocale type but only an English DEFAULT_LOCALE, so hosts had to ship their own translations to get a non-English UI (e.g. the French page in the screenshot rendered an English widget).

  • New packages/shared/src/locales.ts ships LOCALES with English, French, Spanish, and German translations of the full WidgetLocale, plus resolveLocale(language) and detectBrowserLanguage() helpers.
  • WidgetConfig gains an optional language field.
  • KoeContext now resolves the base locale via config.language ?? <html lang> ?? navigator.language, falling back to English. config.locale is still merged on top so hosts can pick a language and override individual keys.
  • New helpers re-exported from @wifsimster/koe.

Usage

Auto-detected from the host page:

<html lang="fr">

Or explicit:

Koe.init({ projectKey: '…', language: 'fr' });

Test plan

  • pnpm turbo run build (all 4 packages)
  • pnpm typecheck (all 4 packages)
  • pnpm test (89 API tests pass)
  • Manual: load widget on a <html lang="fr"> page and confirm French strings render

Generated by Claude Code

The widget had a `WidgetLocale` type but only an English `DEFAULT_LOCALE`,
so hosts had to ship their own translations to get a non-English UI. Add
built-in `LOCALES` (en/fr/es/de) and a `language` config field, and have
the context auto-detect from `<html lang>` or `navigator.language` when
the host doesn't pass one. Hosts can still override individual strings
via `config.locale` on top of the resolved preset.
@Wifsimster
Wifsimster merged commit 6f21b42 into main May 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants