Skip to content

feat(i18n): Add RTL (Right-to-Left) support for Arabic and other RTL languages #10908

Closed

Description

@amrpyt

Feature Request

Summary

Add comprehensive RTL (Right-to-Left) support for Arabic and other RTL languages (Hebrew, Persian, Urdu) to improve accessibility and usability for users in RTL-speaking regions.

Motivation

OpenCode already has Arabic translations (README.ar.md and Arabic locale in the app), but the UI doesn't properly handle RTL text direction. This makes the interface difficult to use for Arabic-speaking users as text alignment, layout, and reading flow are incorrect.

Proposed Solution

1. Add Arabic Font Support

  • Include IBM Plex Sans Arabic font (Regular, Medium, SemiBold weights)
  • Use unicode-range in @font-face to only load Arabic glyphs when needed
  • Add --font-family-arabic CSS variable

2. Create RTL Stylesheet (rtl.css)

  • Text direction and alignment rules for html[dir="rtl"]
  • Preserve LTR for code blocks, file paths, URLs
  • Icon flipping utilities for directional icons (arrows, etc.)
  • Scrollbar positioning adjustments
  • Form input RTL alignment
  • Logical CSS properties (margin-inline-start, padding-inline-end, etc.)

3. Extend i18n Context

  • Add isRTL accessor to detect RTL locale
  • Add direction accessor returning "ltr" or "rtl"
  • Auto-set document.documentElement.dir when locale changes

4. RTL Utility Classes

  • .font-arabic - Explicitly use Arabic font
  • .rtl-flip - Flip icons horizontally
  • .preserve-ltr - Keep content LTR (for code)
  • .text-start / .text-end - RTL-aware alignment
  • .ms-auto / .me-auto - RTL-aware margins

RTL Languages to Support

Locale Language
ar Arabic
he Hebrew
fa Persian (Farsi)
ur Urdu

Implementation Notes

I have a working implementation ready that includes:

  • 3 IBM Plex Sans Arabic font files (~224KB total)
  • fonts-arabic.css with optimized @font-face declarations
  • rtl.css with comprehensive RTL styling
  • Modified i18n.tsx with RTL detection helpers
  • Modified language.tsx to auto-apply dir attribute
  • RTL utility classes in utilities.css

Files Changed: 12 files, +357 lines

Screenshots

The implementation correctly renders Arabic text right-to-left while preserving LTR for code blocks:

┌─────────────────────────────────────────┐
│                          مرحبا بالعالم  │  <- Arabic text aligned right
│                                         │
│  console.log("Hello")                   │  <- Code stays LTR
│                                         │
│                      هذا نص عربي للاختبار │  <- More Arabic text
└─────────────────────────────────────────┘

Additional Context

  • IBM Plex Sans Arabic is the Arabic companion to IBM Plex (already used in OpenCode)
  • Uses unicode-range so fonts only load when Arabic characters are present
  • No breaking changes - LTR languages work exactly as before
  • Tested with standalone HTML and Vite dev server

Contribution

I'm happy to submit a PR with this implementation. Let me know if you'd like any changes to the approach!

Activity

  1. github-actions commented on Jan 27, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if your implementation addresses aspects not covered in these issues.

  2. github-actions commented on Mar 30, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  3. algonomadx-ux commented on May 30, 2026

    @algonomadx-ux

    This issue is marked as closed, but RTL support still seems incomplete.

    For Persian (Farsi):

    • No proper RTL layout
    • Incorrect text rendering
    • Mixed RTL/LTR text is not handled correctly

    Can the maintainers clarify whether RTL support was actually implemented, and if not, what is the current roadmap for it?

    Thank you.

  4. hussainbiedouh commented on May 31, 2026

    @hussainbiedouh

    +1

  5. hossamyosri commented on Jun 6, 2026

    @hossamyosri

    not solved yet

  6. legacymkr commented on Jun 12, 2026

    @legacymkr

    not solved

  7. 2-sa commented on Jun 15, 2026

    @2-sa

    not solved

  8. hussainbiedouh commented on Jun 15, 2026

    @hussainbiedouh

    not solved

  9. razavioo commented on Jun 21, 2026

    @razavioo

    https://github.com/razavioo/opencode-rtl

    I have created an opencode RTL plugin that solves the most part. feel free to check it out.

  10. nkhayatei commented on Jun 24, 2026

    @nkhayatei

    I also have problems with Persian and Arabic.
    Image

  11. orenmizr commented on Jun 25, 2026

    @orenmizr

    was this just ignored ? closed without reason ?

    https://github.com/razavioo/opencode-rtl

    I have created an opencode RTL plugin that solves the most part. feel free to check it out.

    important to note to workaround won't work everywhere:

    tested on apple terminal :

    Image

    tested on warp (ghostty in core)

    Image

    it matters which terminal you're on. ghostty also has rtl issue of its own: ghostty-org/ghostty#1442

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions