Repository navigation
web: add UI translation layer and Turkish locale - #346
Merged
Merged
Conversation
Every user-visible string in the web UI now goes through t() from web/src/i18n. The English source text is the key, so a missing entry falls back to English and nothing breaks; Turkish lives in one flat file, web/src/i18n/locales/tr.json (about 2,600 entries). The locale is chosen once per page load: a saved choice, else the browser language, else English. Switching (new Language toggle under Preferences) stores the choice and reloads, so t() also works in module constants, helpers and toasts without hooks. Also: - hard-coded zh-CN / implicit date locales now follow the UI language - sentences assembled from fragments became single templates - "Toujours autoriser" in approval records is now English - upload.test.mjs stubs the new @/i18n import Values sent to the API or compared in code, agent prompts, and backend messages are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
not-found is prerendered in the build-time locale, so a reader whose browser picks another locale hit a hydration mismatch. Render the translated text after mount instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n CI
t() looked a key up with dict[key] ?? key, so t("constructor") returned
Object and t("toString", {}) threw. Backend values are used as keys, so
this was reachable. Use an own-property check for the dictionary and the
vars, and commit the key-check script as npm run test:i18n in the web
job so tr.json cannot drift.
BaaRai
approved these changes
Nov 19, 2026
BaaRai
left a comment
Owner
There was a problem hiding this comment.
Applied two fixes at d577d7e: t() now uses an own-property check for the dictionary and for vars, so prototype keys cannot resolve or throw, and the key-check script is committed as npm run test:i18n in the web job (2,542 literal keys checked against 2,600 entries). The rest of the review holds; merging after the web job.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The web UI only exists in English, and every string is hard-coded in the components, so it can't be offered in another language. A few spots also hard-code
zh-CNdate formatting, and one approval button reads "Toujours autoriser".Change
web/src/i18n/index.ts.t(key, vars)takes the English source text as the key and returns the string for the active locale.{name}.t()is a plain function. It also works in module constants, column definitions, toasts andlib/helpers, with no hooks or context and nothing for the React Compiler to track.web/src/i18n/locales/tr.json. One flat file with about 2,600 entries. To add a language, addlocales/<code>.jsonand list it inLOCALES.web/srcnow goes throught(): JSX text, placeholders, titles, aria-labels, toasts, displayed errors, option and column labels, and empty states.<b>or<code>, the markup stays inside the translated string and a small local helper renders it.Visible changes for English users
zh-CNdates, and dates with no explicit locale, now follow the UI locale (intlLocale).formatCurrencyand the calendar default to it as well. The date-range picker label now reads "Nov 18, 2026" instead of "18 Nov 2026".export: 500became "Export failed: 500".Deliberately left in English
@[kind#id …]mention labels (parsed back bylib/chat-mentions), and technical labels such as HTTP methods, IP/CIDR, URL and tool names.Testing
All on this branch's HEAD:
npx tsc --noEmitis clean.biome lintreports the same findings asmain.t("…")key has atr.jsonentry with the same{placeholders}.npm run test:polling,test:replay,test:uploadandnode --test src/lib/chat-mentions.test.mjsall pass.upload.test.mjsneeded a stub for the new@/i18nimport.NEXT_PUBLIC_MOCK=1) in headless Edge, with fresh profiles for--lang=trand--lang=en-US:not-foundwas changed to render its text after mount, which is the second commit./system/settingsand/system/notifythrow in mock mode onmaintoo, because the mock data has nohosts/kinds. This PR does not change that.go build -tags embedui) and ran it against PostgreSQL. Pages are served correctly. I have not clicked through every screen while logged in against a real backend, so a review pass in Turkish would be welcome.Known limitations
<title>comes from static metadata, so it is fixed at build time in English.suppressHydrationWarningfor that brief moment.lib/preferences/theme.ts, thet("Default")label sits inside thegenerated:themePresetsblock. Rerunninggenerate:presetswould drop it.Size
This touches about 100 files, more than CONTRIBUTING asks for. The wrapping and the dictionary don't separate well, because wrapped keys without a dictionary just show English. If you prefer, I can split it into:
tr.json.I can also split it by area.
🤖 Generated with Claude Code