rtl-aware-development
它能做什么
它提供规则,使应用和布局在从左到右和从右到左两种方向下都能正常工作,包括逻辑 CSS、文本隔离和图标镜像。适合构建必须支持阿拉伯语、希伯来语或其他 RTL 文字的界面的开发者。
适用场景
- ✓当你在构建或审查一个必须支持从右到左语言的布局时。
- ✓当 CSS 中使用的左右值在 RTL 文本下应当翻转时。
- ✓当混合的英文和 RTL 文本或文件路径在菜单或列表中显示不正确时。
技能链接
https://github.com/Kilo-Org/kilocode/blob/main/.opencode/skills/rtl-aware-development/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“切换到阿拉伯语时,我的界面会出错。请审查 CSS,并告诉我需要修改什么,以使布局正确翻转。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体检查文档方向,把物理意义上的左右 CSS 替换为逻辑属性,并隔离混合方向的文本。它只镜像具有方向含义的图标,而品牌标志、图表和媒体控件则保持不变。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
RTL-Aware Development
Treat direction as independent from language. Test English in both directions as well as real RTL and mixed-script content.
Guidelines
- Set
langanddiron the document, and propagate direction through component providers used by portaled menus and popovers. Do not change the selected locale merely to force RTL. - Keep DOM and focus order semantic. Flexbox and Grid already follow
dir; do not addrow-reverse, CSSorder, or reversed markup just to mirror a layout. - Prefer logical CSS for semantic layout. Reserve physical coordinates for pointer positions, canvas geometry, native window controls, and other genuinely physical placement.
/* Avoid */
padding-left: 12px;
right: 0;
border-right: 1px solid;
text-align: left;
/* Prefer */
padding-inline-start: 12px;
inset-inline-end: 0;
border-inline-end: 1px solid;
text-align: start;
- Isolate mixed-direction text. Use
dir="auto"or<bdi>for unknown text; keep code, URLs, IDs, and filesystem paths LTR without forcing the surrounding component LTR.
<span class="file-row"><bdi dir="auto">README.md</bdi></span> <bdi dir="ltr"><code>C:\src\app.ts</code></bdi>
- Mirror directional meaning, not every image. Back/forward, previous/next, disclosure, indentation, and directional progress may need mirroring. Do not mirror brands, clocks, media controls, charts, or text. Reverse physical gradients,
translateX, SVG transforms, and animation deltas explicitly. - Map interactions through direction.
clientXremains physical; resizing a logical edge needs an RTL-aware delta. Logical previous/next keyboard controls may swap ArrowLeft/ArrowRight. Follow the relevant WAI-ARIA widget pattern. - Do not assume LTR scrolling. RTL
scrollLeftcan start at0and become negative. PreferscrollIntoView({ inline: "nearest" })or a tested direction-normalizing helper. - For Electron title bars, prefer native caption controls and use
titleBarOverlayplusenv(titlebar-area-*)for the safe content rectangle. Keep Windows/macOS native-control avoidance andtrafficLightPositionphysical; keep app navigation inside that rectangle logical. Mark interactive titlebar childrenapp-region: no-drag. - Verify behavior, not screenshots alone. Check computed styles, pseudo-element geometry, hit zones, focus order, keyboard behavior, submenu direction, zoom/scaling, and both LTR and RTL scroll endpoints.
Test Matrix
- English + LTR
- English + forced RTL
- A real RTL locale + RTL
- Mixed RTL/LTR content, long labels, numbers, code, and paths
- Keyboard, pointer resize, scrolling, menus/submenus, and Electron titlebar controls in both directions
References
- RTL Styling 101, Ahmad Shadeed
- CSS-Tricks: RTL Styling 101
- CSS-Tricks: CSS Logical Properties and Values
- W3C: Structural markup and right-to-left text
- W3C: Inline bidirectional markup
- MDN: CSS logical properties and values
- MDN:
dir - MDN:
scrollLeft - web.dev: Logical properties
- Electron: Custom title bar
- WAI-ARIA: Window splitter pattern
- Kobalte: I18n Provider
常见问题
什么是逻辑 CSS?
它使用 start 和 end 代替 left 和 right,因此布局会对从右到左的文本自动翻转。
是否每个图标都应该镜像?
不是。只有具有方向含义的图标,例如返回或下一步,才会被镜像。
混合文本如何处理?
未知文本会添加方向属性或 bdi 标签,代码、URL 和路径则保持从左到右。
详情
作者的原始描述
OpenCode Desktop should be RTL-aware. Use when implementing or reviewing RTL/LTR behavior in the web app, desktop app, CSS, menus, scrolling, resizing, icons, mixed-direction text, or Electron title bars.
repo: Kilo-Org/kilocode
热度
- GitHub 星标
- 28k
- 排名
- #9875
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …