Skip to content

Localisation: right-to-left languages - #1140

Merged
ivanfenenko merged 12 commits into
mainfrom
feature/1139-rtl-languages
Nov 29, 2026
Merged

ivanfenenko merged 12 commits into
mainfrom
feature/1139-rtl-languages

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follows #1138 (56 left-to-right languages).

Six right-to-left languages, iOS and Android: Arabic, Hebrew, Persian, Urdu, Dhivehi and Punjabi in the Shahmukhi script, the right-to-left languages the OpenCode desktop app ships. Every app string and iOS permission prompt (1,525 strings each), translated with the translate skill, then one consistency pass per language. Hebrew keeps Android's old iw folder; Punjabi is pa-Arab / b+pa+Arab so a device set to Gurmukhi Punjabi doesn't get Shahmukhi text. l10n/terms.json records each language's chosen words for later translations.

Right-to-left layout fixes found on the emulator and simulator in Arabic:

  • Messages read in their own direction. markdown-core records each message's direction from its first letter outside code (MarkdownDocument.direction); both apps lay the rendered message out in it. An English reply in an Arabic app keeps its headings, list numbers and table columns left to right; an Arabic reply in an English app reads right to left.
  • Gestures follow the finger (Android). Compose touch positions stay physical while offset {} mirrors, so the message time reveal, request paging in the composer, list swipe actions and the session list dock went the wrong way. They go through LayoutDirection.alongLayout; the dock's arrow keys swap too.
  • Code stays left to right. Code files, unified diffs and Markdown code and diff blocks on both platforms (iOS code files weren't before; parity with Android).
  • Values keep their order. Android UiText arguments are isolated in right-to-left languages, as iOS formatting already does, and agent names and diagnostics timestamps are isolated on both, so arrows and patterns (node *) stay in place. Project paths on Android Home and the session list dock, and the literal paths in two translated strings, are marked left to right (~/projects/app showed as projects/app/~).
  • Release notes (English in every language) take their own paragraph direction on Android, so a sentence ends with its full stop, as on iOS.
  • Arrow strings ("Settings → Timeline Style") use ← in right-to-left translations.

Component audit fixes. A walk of the component gallery in Arabic on both apps plus a code review against Apple HIG "Right to left" and Material "Bidirectionality" found 17 problems; all are fixed:

  • Gestures on iOS follow the finger too (SwiftUI drag translations are physical): message time reveal, session list dock, composer request paging, row swipe actions, via an iOS LayoutDirection.alongLayout.
  • Custom drawing mirrors: chart plots (with their already-mirrored labels), the skeleton illustration, Android's step rail line and text size slider track. The context ring and task arc keep filling clockwise from the top.
  • Popups open from their anchor's leading edge and stay on screen: overflow menus on both apps, the branch pill's anchored card, Android's right-click menu at the pointer.
  • Left-to-right data stays left to right: the server address row, code snippets and shell commands, and paths, URLs, commands and mentions inside shared Android components (List Item, Picker Card, Action Bar, Timeline Notice, composer suggestions).
  • Android plain-text messages and activity card text take their own paragraph direction; a feature item's title and body share one.
  • The tree row's expanded chevron points down on iOS; six more icons mirror (list, text_select, description, message_square, rate_review, arrow_warm_up) on both apps.
  • Right-to-left translations made only of placeholders ("{1} · {2}") start with a right-to-left mark so their parts don't swap; apply adds it and check-translations requires it.

Tooling: the consistency review showed Android's translation on the #ios row of a key worded per platform; it now reads each row from its own platform. The translate skill says how to treat arrows and literal paths in right-to-left languages.

Checks

  • node scripts/check-translations.mjs: 62 languages × 1525 strings on Android and iOS.
  • node --test scripts/l10n/*.test.mjs, check-string-keys.mjs, gitleaks: pass.
  • Android :app:testDebugUnitTest and :markdown-core:testDebugUnitTest pass (new OpenCodeLayoutDirectionTest, MarkdownTextDirectionTest).
  • iOS unit tests: 3,838 pass (new MarkdownDirectionTests, OpenCodeLayoutDirectionTests, OverflowMenuPanelGeometryTests, anchored card RTL cases).
  • Android unit tests: 3,621 pass (new OverflowMenuPlacementTest, OpenCodeTextDirectionTest, layout direction and anchored card RTL cases); check-icons.mjs passes.
  • Component gallery walked in Arabic on both apps before and after the fixes; English rechecked for changed components; iOS gestures checked with held drags in Arabic and English.
  • Visual check in Arabic against the scenario harness (v2): Home, Session Chat (Markdown reply, tool loop, permission request), Settings, What's new and the timeline style picker on both apps; the Android time reveal by a held drag.

Evidence

Screenshots in the evidence comment.

Issue

Fixes #1139

Risks / Follow-ups

  • No native-speaker review. Dhivehi and Shahmukhi Punjabi are low-resource languages for the models; each consistency pass listed words for a speaker to check.
  • Not tried on a device: composer request paging (needs several waiting requests; same helper as the verified gestures, unit tested), the iOS task arc, Android right-click placement (the emulator sends no right clicks; unit tested), long-press reordering.
  • The dev-only Playground capsule still has unmirrored drag and ring code.
  • Android: direct stringResource(id, args) calls don't go through UiText, so their arguments aren't isolated; paths in shared components are handled, but a Latin name in another such string can still reorder.
  • Only Arabic was checked on devices; the other five share the same layout code.
  • v1 protocol not checked (no v1 server on the test machine); the changes are layout only.

Adds Arabic, Hebrew, Persian, Urdu, Dhivehi and Punjabi in the
Shahmukhi script, the right-to-left languages the OpenCode desktop app
ships, on iOS and Android: every app string and iOS permission prompt.

- languages.mjs lists them with their plural forms and scripts (Arabic,
  Hebrew, Thaana ranges for the wrong-script check). Android keeps the
  old code iw for Hebrew; Punjabi is pa-Arab / b+pa+Arab so devices set
  to Gurmukhi Punjabi don't get Shahmukhi text.
- desktop-terms.json gains the desktop app's words for the six; the
  existing 56 languages keep the words they were translated with.
- terms.json records each language's chosen words from a consistency
  pass, so later translations reuse them.
- Arrow strings use ← in right-to-left text.
A string worded per platform (id#android, id#ios) showed the Android
translation on both rows, so reviewers saw iOS App Lock text with
Android's unlock methods and rewrote it. The iOS strings were right;
the review now reads each row from its own platform.
…youts

Android:
- Touch positions stay physical in a right-to-left layout while offset
  and alignment mirror, so drags that move mirrored content go through
  LayoutDirection.alongLayout: the message time reveal, request paging
  in the composer, list swipe actions and the session list dock. The
  dock's Left and Right arrow keys swap too.
- The unified diff and Markdown code and diff blocks lay out left to
  right, like the code file viewer already did.

iOS:
- The code file viewer, unified diff and Markdown code and diff blocks
  lay out left to right, matching Android.

Both:
- Agent names in the agent-change notice and the diagnostics range
  timestamps are wrapped in Unicode isolates, so the arrow between them
  follows right-to-left text.
An English reply in a right-to-left app had its headings, list numbers
and table columns mirrored, and an Arabic reply in a left-to-right app
the reverse. markdown-core now records the text's direction from its
first letter outside code (MarkdownDocument.direction), and both apps
lay the rendered message out in it; the chrome around it keeps the
app's direction.
…ents

Found on the emulator in Arabic:
- Compose took each paragraph's direction from the layout, so English
  text in a right-to-left screen put its full stop on the left. Every
  typography style now uses TextDirection.Content, like iOS text; code
  falls back to left to right.
- In a right-to-left language, UiText arguments are wrapped in Unicode
  isolates, as iOS formatting does, so a path or pattern can't reorder
  the sentence; the always-allow pattern in a permission request
  ("node *") gets the same.
"Show ~/Projects/… instead of /Users/you/Projects/…" and the health
check path in onboarding scrambled their slashes in right-to-left text.
The paths in those two strings are wrapped in Unicode isolates in the
six right-to-left languages, and the translate skill says how to treat
arrows and literal paths in those languages.
Content direction on every typography style aligned English session
titles and project names to the far edge in a right-to-left Home, so
it is back to the layout's direction. Instead:
- Release notes (OpenCodeFeatureItem), which are English in every
  language, take their own direction so a sentence ends with its full
  stop; code keeps ContentOrLtr.
- Project paths on Home, the session list dock and the run-in card are
  marked left to right, so "~/projects/app" no longer shows as
  "projects/app/~". Marks rather than an isolate: an ellipsized label
  loses the closing isolate.
iOS text drew "~/Projects/…" as "…/Projects/~" even inside a
first-strong isolate. A left-to-right mark at both ends of each literal
path keeps it in order on both platforms; the translate skill says the
same.
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

iOS and Android in Arabic, against the scenario harness (v2 protocol, harness data only).

Step iOS Android
Home: mirrored rows, project path reads left to right iOS home Android home
English reply in an Arabic app: headings, list numbers and table read left to right; code stays left to right iOS message Android message
Settings: mirrored, literal paths in order iOS settings Android settings
Time reveal dragging the bubble toward the start (right); permission pattern node * in order Android time reveal

A right-to-left translation with no letters outside its placeholders
("{1} · {2}", "{1} ← {2}") laid out left to right, so the Background
Work Pill counter and the agent-change notice swapped their parts.
The 29 such keys start with a right-to-left mark in the six
right-to-left languages; apply adds the mark and check-translations
requires it, so a later translation keeps it.
list, text_select, description, message_square, rate_review and
arrow_warm_up show text flow or direction, so they mirror like the
arrows and chevrons (Apple HIG and Material). Set in the icon manifest
and regenerated for both platforms.
From walking the component gallery in Arabic:
- Gestures follow the finger: SwiftUI drag translations are physical
  while offsets mirror, so the message time reveal, session list dock
  paging, composer request paging and row swipe actions go through a
  new LayoutDirection.alongLayout, like Android.
- Charts mirror their time-based plots with their labels; the skeleton
  illustration mirrors (its URL stays left to right).
- The anchored overflow menu and the branch pill's anchored card open
  from the anchor's leading edge and stay on screen.
- The server address row, code snippets and shell commands read left
  to right.
- The tree row's expanded chevron points down; the context ring and
  task arc fill clockwise from the top.
From walking the component gallery in Arabic:
- Step rail lines, the text size slider's track and ticks, chart plots
  and the skeleton illustration draw by layout direction instead of
  from the physical left.
- The top-bar overflow menu opens from its anchor's leading edge, the
  branch pill's anchored card sizes from the pill's leading edge, and a
  right-click menu opens at the pointer (OverflowMenuPlacement).
- Shared components keep paths, URLs, commands and mentions left to
  right themselves (List Item subtitleReadsLeftToRight, Picker Card
  footnoteIsPath, Action Bar, Timeline Notice, composer suggestions),
  replacing the per-screen marks.
- Plain-text messages and activity card text take their own paragraph
  direction like rendered Markdown; a feature item's title and body
  share one direction.
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Right-to-left audit fixes, iOS and Android in Arabic (component gallery and harness data, v2 protocol).

Step iOS Android
Charts: plots mirror with their labels, newest under "now"
Overflow menus open from their anchor, on screen
Branch pill's anchored card sizes from the pill's leading edge
Time reveal follows a rightward drag (held drag, mid-gesture) (earlier comment)
Tree row: expanded chevron points down
Background work counter reads in order
Step rail line runs through its dots
Text size slider fills from the start
List item paths read left to right
Plain-text message keeps its punctuation at the end

@ivanfenenko
ivanfenenko marked this pull request as ready for review November 29, 2026 16:44

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: 1 finding(s) that 2+ of 3 passes agreed on.

1 finding(s) from a single pass, not posted
  • ios/OpenCode Mobile/OpenCode Mobile/Components/List/OpenCodeTreeRow.swift:140 medium: Expanded folder chevron rotates the wrong way in right-to-left (deepseek-v4.1-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.152 · 1 pass(es) stopped early

// Hebrew, Arabic, Syriac, Thaana, NKo, Samaritan, Mandaic and the Arabic extensions and
// presentation forms.
private fun isRightToLeft(ch: Char): Boolean =
ch in '֐'..'ࣿ' || ch in 'יִ'..'﷿' || ch in 'ﹰ'..''

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low: U+FEFF (BOM/ZWNBSP) is treated as a right-to-left letter

The last range of isRightToLeft ('ﹰ'..'') ends at U+FEFF, and textDirection() checks isRightToLeft(ch) before ch.isLetter(). U+FEFF is a format character (zero-width no-break space / BOM), not an RTL letter, but the loop returns "rtl" as soon as it is seen, before any real letter is reached.

Failure scenario: An English message whose text contains a U+FEFF before the first letter (e.g. a copy-pasted reply that carries a BOM artifact from a Windows editor) -> markdownTextDirection() returns "rtl" -> the English reply is laid out right-to-left in the chat: right-aligned, mirrored headings, list numbers and table columns, despite being plain left-to-right English.

Found by 2 of 3 passes.

@ivanfenenko
ivanfenenko added this pull request to the merge queue Nov 29, 2026
Merged via the queue into main with commit 5cef376 Nov 29, 2026
31 checks passed
@ivanfenenko
ivanfenenko deleted the feature/1139-rtl-languages branch November 29, 2026 17:08
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.

Localisation: right-to-left languages

1 participant