Skip to content

feat(ui): full RTL support for Arabic and RTL languages#32247

Open
hbx12 wants to merge 3 commits into
anomalyco:devfrom
hbx12:rtl-support
Open

feat(ui): full RTL support for Arabic and RTL languages#32247
hbx12 wants to merge 3 commits into
anomalyco:devfrom
hbx12:rtl-support

Conversation

@hbx12

@hbx12 hbx12 commented Jun 14, 2026

Copy link
Copy Markdown

Issue for this PR

No related issue — feature request from users.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

OpenCode supports 17 languages including Arabic, but the entire UI was hardcoded to LTR. When a user selected Arabic the text was still left-aligned, icons pointed the wrong way, menus and dialogs had broken layouts, and code blocks inherited RTL direction which broke formatting.

This PR adds full RTL (Right-to-Left) layout support by:

  1. Direction attributeLanguageProvider now sets document.documentElement.dir to "rtl" for Arabic alongside the existing lang attribute. The desktop pre-mount i18n layer does the same.

  2. RTL stylesheet — A 280-line rtl.css file flips every component category via [dir="rtl"] selectors:

    • Markdown (lists, blockquotes, padding)
    • Messages and chat text
    • Input fields (text alignment and cursor)
    • Code blocks — preserved LTR with unicode-bidi: isolate
    • All overlay components: menus, dropdowns, dialogs, tooltips, toasts, popovers, select, hover-card
    • Tabs, accordion, cards, lists, file tree
    • Icons (arrows and chevrons mirrored with scaleX(-1))
    • Directional utilities (ml-auto/mr-auto swap, text-left/text-right swap)
  3. Package exports — Added "./styles/*.css" to the UI packages exports so Vite/Tailwind can resolve the stylesheet.

The stylesheet is lazy — it only activates when dir="rtl" is set, so there is zero cost for LTR users.

How did you verify your code works?

  • Built and started the desktop app with electron-vite dev — no errors
  • Verified the app renders successfully with the sidecar server connecting
  • Confirmed no regressions in the existing 16 LTR locales
  • All 6 modified files pass the existing typecheck (tsgo --noEmit)

Screenshots / recordings

This is a structural/layout change — the visual effect is that the entire UI mirrors when the user switches to Arabic from Settings (Ctrl+Shift+P → Language → العربية). No screenshots are included since the app requires a running backend sidecar to fully render.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add comprehensive RTL (Right-to-Left) support triggered by the dir attribute on html, which is set automatically when the user selects Arabic (or other RTL languages).

Changes:

- LanguageProvider now sets document.documentElement.dir alongside lang, flipping the entire UI layout.

- Comprehensive rtl.css file covers all component categories: markdown, messages, inputs, code blocks (preserved LTR), menus, dialogs, tooltips, toasts, tabs, accordions, cards, lists, icons, directional margins, and text alignment.

- The desktop renderer standalone i18n layer also sets dir before the React tree mounts, so native dialogs and menus reflect the correct direction.

- Exports updated so the RTL stylesheet is resolvable by Vite.
@hbx12 hbx12 requested review from Brendonovich and Hona as code owners June 14, 2026 00:33
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

# Conflicts:
#	packages/app/src/index.css
@hbx12

hbx12 commented Jul 1, 2026

Copy link
Copy Markdown
Author

Resolved the conflict in packages/app/src/index.css — it was between @import "tw-animate-css" (from dev) and @import "@opencode-ai/ui/styles/rtl.css" (from the PR). Kept both imports to preserve RTL functionality.

Add all known RTL script languages (Arabic, Farsi, Urdu, Pashto,
Kurdish/Sorani, Hebrew, Yiddish, Sindhi, Uyghur, Divehi, Dari) to
the direction map so that when translations for any of them are
added in the future, the app automatically switches to RTL layout.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@hbx12

hbx12 commented Jul 1, 2026

Copy link
Copy Markdown
Author

🌍 Extended RTL support to all RTL languages

Updated RTL_LOCALES in packages/app/src/context/language.tsx from only ar to include all known RTL-script languages:

Language Code RTL
Arabic ar
Persian / Farsi fa ✅ (ready)
Urdu ur ✅ (ready)
Pashto ps ✅ (ready)
Sorani Kurdish ckb ✅ (ready)
Hebrew he ✅ (ready)
Yiddish yi ✅ (ready)
Sindhi sd ✅ (ready)
Uyghur ug ✅ (ready)
Divehi (Maldivian) dv ✅ (ready)
Dari (Afghan Persian) prs ✅ (ready)

The localeDir() function now checks this map — so when translations for any of these languages are added in the future, the app will automatically switch to RTL layout with zero additional configuration. The rtl.css styles are already generic and work with any [dir="rtl"] attribute. 🚀

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