Skip to content

Add Japanese, Chinese, and French translations with a topbar language switcher - #2

Merged
encoreshao merged 1 commit into
mainfrom
feature/i18n
Oct 4, 2026
Merged

encoreshao merged 1 commit into
mainfrom
feature/i18n

Conversation

@encoreshao

Copy link
Copy Markdown
Owner

Summary

  • New bin/i18n.py: per-request-thread translation lookup keyed by the English source string; catalogs in bin/locales/{ja,zh,fr}.json (~580 strings each).
  • Language resolution: loop_lang cookie → Accept-Language → English. <html lang> set accordingly.
  • Every dashboard page, sidebar/nav, page titles, buttons, tables, empty states, tooltips, confirm dialog, flash messages, inbox setup wizard, and JS-rendered text go through _t().
  • Topbar language switcher: translate icon + current code (EN/JA/ZH/FR), menu of native language names; keyboard accessible; sets the cookie and reloads.
  • CLAUDE.md documents the _t() convention for new UI strings.

Intentionally left in English: product names, user/config data, log output, and the chat suggestion prompts (they are sent to the AI).

Testing

  • python3 -m pytest tests/ -q → 1829 passed, 15 xfailed, 2 xpassed.
  • tests/test_i18n.py enforces that every _t() literal has an entry in all three catalogs with matching {placeholders}; English output is unchanged.
  • Sandboxed dev server: all 24 pages return 200 in all four languages; attribute structure identical across languages; all inline scripts parse.

… switcher

Introduce bin/i18n.py: a per-request-thread translation lookup keyed by the
English source string, with catalogs in bin/locales/{ja,zh,fr}.json. The
dashboard resolves the language from a loop_lang cookie, then
Accept-Language, then English, and renders every page, flash message, and
inline script string through _t(). A translate-icon menu in the topbar sets
the cookie and reloads.

tests/test_i18n.py checks that every _t() literal in bin/web has an entry
in each catalog with matching format placeholders.
@encoreshao
encoreshao merged commit befcdaf into main Oct 4, 2026
1 check passed
@encoreshao encoreshao self-assigned this Oct 4, 2026
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