feat(i18n): add Persian (fa) locale with RTL — desktop + dashboard - #86335
Open
blackorange-mega wants to merge 4 commits into
Open
feat(i18n): add Persian (fa) locale with RTL — desktop + dashboard#86335blackorange-mega wants to merge 4 commits into
blackorange-mega wants to merge 4 commits into
Conversation
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.
What does this PR do?
Adds Persian (Farsi,
fa) as a selectable UI language in both graphical front-ends — the Electron desktop app and the web dashboard — including right-to-left layout.Persian was missing from both GUI catalogs:
apps/desktop/src/i18n/shippeden,zh,zh-hant,ja,ar, andweb/src/i18n/shipped 17 locales with nofa.Why this approach. It mirrors #70870 (
feat(i18n): Arabic (ar) locale with RTL support), which is the existing precedent for adding one language across the GUI surfaces. As #76854 notes, the RTL infrastructure already exists, so this is a translation change rather than an architectural one —fajoins theRTL_LOCALESsets and inherits the plumbing Arabic already uses.The issue asks only for the desktop app. The dashboard is included because it is the other GUI, has the same gap, and follows the same three-line registration — leaving it out would ship a half-Persian product for the same review cost.
Scope — and what this deliberately leaves alone
This PR touches only the two GUI catalogs. It does not add
locales/fa.yamland does not registerfainagent/i18n.py.That CLI/gateway half is already covered by the open, approved #53398, and
CONTRIBUTING.mdasks contributors to improve an existing PR rather than open a competing one. The two are complementary and can land in either order — the desktop and dashboard catalogs are independent TypeScript modules with their ownLocaleunion, so nothing here depends on the Python side.Related Issue
Fixes #76854
Type of Change
Changes Made
Desktop (
apps/desktop/src/i18n/)fa.ts— new. Persian catalog built withdefineLocale(), so English keys added later fall back cleanly instead of breaking the buildtypes.ts—faadded to theLocaleunioncatalog.ts— registered inTRANSLATIONSlanguages.ts— picker entry (endonymفارسی,englishName: 'Persian'for search) plus aliasesfa-IR,fa-AF,persian,farsi,فارسیcontext.tsx—faadded toRTL_LOCALEScontext.test.tsx,languages.test.ts— new coverageDashboard (
web/src/i18n/)fa.ts— new. Persian catalog built withdefineLocale()types.ts—faadded to theLocaleunioncontext.tsx—TRANSLATIONS,LOCALE_META(endonymفارسی),RTL_LOCALESRTL
No new CSS. Both providers already set
document.documentElement.dirfromRTL_LOCALES, and the dashboard'shtml[dir="rtl"]rule inindex.cssis language-agnostic, so Tailwind's logical utilities (ms-/me-,ps-/pe-) flip for Persian exactly as they do for Arabic.Chat-message bidi is unaffected — that resolves per-message from content via
dir="auto"(#44596), independently of UI language.Translation notes
{placeholder}tokens and arrow-function signatures are preserved verbatim; the dashboard catalog was checked againsten.tsfor placeholder parity.MCP,OAuth,PKCE,YAML,SSH).ar.tsand the Latin numerals produced by runtime interpolation — mixing Eastern Arabic-Indic digits into interpolated strings would render inconsistently.میشود,بهروزرسانی).fa-AF) aliases to this catalog rather than falling back to English. Dari and Iranian Persian differ in vocabulary and register but share an orthography and are mutually intelligible in writing, so a shared catalog serves Afghan users far better than English. If Dari-specific strings are wanted later,prscan be split out without disturbing this locale.How to Test
npm install --workspace apps/desktop && npm --workspace apps/desktop run devnpm install --workspace web && npm --workspace web run dev) via the language switcher.display.language: fain~/.hermes/config.yaml. Settingfa-IR,farsi, orفارسیthere also resolves to Persian.npm --workspace apps/desktop exec vitest run src/i18nandnpm --workspace web exec vitest run.Tests added
context.test.tsx— Persian setsdir="rtl"/lang="fa"and reverts to LTR on switch back, matching the existing Arabic caselanguages.test.ts—fa,FA-IR,fa_af,Farsi, andفارسیall normalize tofa;fa-IRis a supported config value but not aLocaleidChecklist
Code
fa, intentionally not duplicated here). No open PR addsfato either GUI catalog.pytest tests/ -qand all tests pass — N/A, no Python touched. This is a TypeScript-only change; the equivalent JS suites were run instead (below).Documentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys — N/A (no new keys;display.languagealready exists and simply accepts one more value)CONTRIBUTING.mdorAGENTS.md— N/A (no architecture or workflow change)dirattribute; no platform-specific paths or APIsassistant.tool.titlesare translated)Verification
tsc --noEmit— clean, desktop and webvitest run src/i18n(desktop) — 29/29 passvitest run(web) — 218/218 passeslint— 0 errors on every touched pathprettier --check apps/desktop/src/i18n/— clean. Theweb/tree is not Prettier-governed under the root config (web/src/i18n/en.tsandar.tsdo not satisfy it either), soweb/src/i18n/fa.tsfollows the double-quote, semicolon style of its siblings instead.One note in the interest of full disclosure: the full desktop suite has pre-existing flaky failures on
maininmessaging/index,gateway-settings, andskills/index(DOM queries matching multiple elements). Measured on this machine,mainalone fails 47 tests across 12 files; with this branch applied it is 42 across 11. This change neither causes nor fixes them — it only touchessrc/i18n/.Summary by CodeRabbit
New Features
Bug Fixes