Repository navigation
Localisation: right-to-left languages - #1140
Conversation
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.
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.
|
Right-to-left audit fixes, iOS and Android in Arabic (component gallery and harness data, v2 protocol).
|
There was a problem hiding this comment.
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:140medium: 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 'ﹰ'..'' |
There was a problem hiding this comment.
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.




















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
iwfolder; Punjabi ispa-Arab/b+pa+Arabso a device set to Gurmukhi Punjabi doesn't get Shahmukhi text.l10n/terms.jsonrecords each language's chosen words for later translations.Right-to-left layout fixes found on the emulator and simulator in Arabic:
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.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 throughLayoutDirection.alongLayout; the dock's arrow keys swap too.UiTextarguments 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/appshowed asprojects/app/~).←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:
LayoutDirection.alongLayout.applyadds it andcheck-translationsrequires it.Tooling: the consistency review showed Android's translation on the
#iosrow 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.:app:testDebugUnitTestand:markdown-core:testDebugUnitTestpass (newOpenCodeLayoutDirectionTest,MarkdownTextDirectionTest).MarkdownDirectionTests,OpenCodeLayoutDirectionTests,OverflowMenuPanelGeometryTests, anchored card RTL cases).OverflowMenuPlacementTest,OpenCodeTextDirectionTest, layout direction and anchored card RTL cases);check-icons.mjspasses.Evidence
Screenshots in the evidence comment.
Issue
Fixes #1139
Risks / Follow-ups
stringResource(id, args)calls don't go throughUiText, so their arguments aren't isolated; paths in shared components are handled, but a Latin name in another such string can still reorder.