Skip to content

feat: General Translation i18n for the landing and chat UI - #27

Open
FloareDor wants to merge 1 commit into
mainfrom
general-translation
Open

FloareDor wants to merge 1 commit into
mainfrom
general-translation

Conversation

@FloareDor

Copy link
Copy Markdown
Owner

Summary

Wires gt-next into the app and localizes every user-facing string in the landing page and the chat interface. Dev pages (/eval, /ablation, /metrics, /storage) are deliberately left untranslated.

Setup

  • withGTConfig wraps next.config.ts; existing turbopack/webpack/WASM options unchanged
  • gt.config.json — source en, targets es/fr/de/ja/zh, output public/_gt/ (gitignored, generated)
  • src/loadTranslations.ts returns {} on a miss, so the app runs untranslated when no translation files exist
  • GTProvider + <html lang={useLocale()}> in the root layout, LocaleSelector in the landing nav, generateMetadata() for title/description
  • npm run gt:generate / npm run gt:translate

Strings (228 extracted)

  • JSX prose uses <T>, plain strings use useGT(), counts use <Plural>/<Num>, interpolation uses ICU {name} placeholders
  • src/lib/llm.ts error text is declared with msg() and decoded at the render site, so the English-keyword matchers in chatUtils keep working regardless of locale
  • Left as-is: technical identifiers (rag/agent, provider names, AST node kinds) and byok-vault's getUserMessage (third-party)

Verification

Built, served, and requested with Accept-Language: es against hand-written sentinel translations:

  • <html lang="es"> — locale detection from request headers works
  • gt() strings, the <T> hero block (nested <br/> preserved), and <title> all resolved to the sentinels
  • English requests unaffected; no English remnants left in the Spanish render

The msg()/m() path is verified by implementation + catalog rather than in-browser: useMessages delegates a plain string straight to gt() (the path proven above), and the lib strings are confirmed present in the generated catalog.

Known trade-off

GTProvider reads request headers/cookies, which turns five previously static routes (/, /ablation, /eval, /metrics, /storage) into server-rendered-on-demand. Measured against main to confirm.

A client-side provider was built and tested: it restores static output exactly, but locale detection silently stops working — isLocaleSupported/getDefaultLocale read gt-i18n's I18nConfig singleton, which gt-next only initializes through its server provider, and gt-next exports no public client initializer. Making it work needs initializeGTSPA from gt-react (an undeclared transitive dep) plus gt-i18n/internal/cookies, so it was not shipped.

These pages do their real work in the browser, so the dynamic routes serve a thin HTML shell — the cost is CDN caching of that shell, not compute.

Pre-Landing Review

2 issues (0 critical, 2 informational).

  • src/app/[owner]/[repo]/page.tsx:1118 — shouldSuggestGitHubToken(toastMessage) matches English keywords, but several toasts are now translated at set-time, so the "Get a token" hint becomes locale-dependent. Same coupling at :408, :422, :990 via shouldPromptForLLMSettings. Fix: carry a structured flag instead of re-sniffing text.
  • src/app/[owner]/[repo]/page.tsx:262,299,492,519,643 — gt used inside these callbacks/effects without being in their dependency arrays. Moot in practice (GT's setLocale triggers a full page reload), but worth tidying.

Test plan

  • npm run test:ci — 53 tests, 7 files, 0 failures
  • npm run typecheck — clean
  • npm run build — succeeds
  • Runtime locale verification (see above)
  • Real translations pending: set GT_PROJECT_ID + GT_API_KEY, then npm run gt:translate

Note: build was intentionally left as-is rather than becoming gt translate && next build, since that would break any build without a GT API key.

🤖 Generated with Claude Code

Wires gt-next into the app and localizes every user-facing string in the
landing page and the chat interface. Dev pages (/eval, /ablation, /metrics,
/storage) are deliberately left untranslated.

Setup:
- withGTConfig wraps next.config.ts; existing turbopack/webpack/WASM options
  are unchanged
- gt.config.json: source en, targets es/fr/de/ja/zh, output public/_gt/
  (gitignored, generated)
- src/loadTranslations.ts returns {} on a miss, so the app runs untranslated
  when no translation files exist
- GTProvider + <html lang={useLocale()}> in the root layout, LocaleSelector in
  the landing nav, generateMetadata() for the page title/description

Strings:
- JSX prose uses <T>, plain strings use useGT(), counts use <Plural>/<Num>,
  interpolation uses ICU {name} placeholders
- src/lib/llm.ts error text is declared with msg() and decoded at the render
  site, so the English-keyword matchers in chatUtils keep working regardless
  of locale
- Technical identifiers (rag/agent, provider names, AST node kinds) and
  byok-vault's getUserMessage are left as-is

228 strings extracted. Verified end to end: built, served, and requested with
Accept-Language: es against sentinel translations — html lang, gt() strings,
<T> blocks and <title> all resolved; English requests unaffected.

Known trade-off: GTProvider reads request headers/cookies, which turns the
five previously static routes into server-rendered-on-demand. A client-side
provider restores static output but breaks locale detection, since gt-next
exposes no public way to initialize its I18nConfig in the browser.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
gitask Ready Ready Preview Nov 24, 2026 6:45am UTC

This branch was successfully deployed

1 active deployment
Preview — f813321a Deployed Nov 24, 2026 by vercel[bot]
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