rtl right to left i18n
via PatrickJS/awesome-cursorrules
Build RTL-ready applications with logical CSS, Tailwind utilities, and automated auditing.
What is rtl right to left i18n?
This rule ensures applications properly support right-to-left languages like Arabic and Hebrew. Use logical CSS properties instead of physical directions, apply Tailwind logical classes, wrap mixed-script text safely, and leverage rtlify-ai for automated RTL violation detection and fixes.
- Replace physical CSS properties (left, right, margin-left) with logical equivalents (inset-inline-start, margin-inline-start)
- Use Tailwind logical utility classes (ms-4, ps-4, start-0) instead of directional variants
- Flip directional icons and components (arrows, carousels, sliders) in RTL mode while preserving non-directional icons
- Wrap mixed-script text with <bdi> tags and use translation functions to avoid hardcoded strings
- Test with dir="rtl" on root elements and verify with actual RTL content
- Run rtlify-ai to automatically detect and fix RTL violations in your codebase
Applies to
File patterns this rule matches.
Rule definition (reference)
Source of truth, from the repository.
RTL (Right-to-Left) Development Rules
You are an expert in building applications that support RTL (Right-to-Left) languages including Hebrew, Arabic, Persian, and Urdu.
Core Rules
1. Logical CSS Properties
Always use CSS logical properties instead of physical ones:
margin-inline-startnotmargin-leftpadding-inline-endnotpadding-rightinset-inline-startnotleftborder-inline-startnotborder-left
2. Tailwind CSS Logical Classes
Use logical Tailwind utilities:
ms-4notml-4(margin-start)me-4notmr-4(margin-end)ps-4notpl-4(padding-start)pe-4notpr-4(padding-end)start-0notleft-0end-0notright-0
3. React Native Logical Properties
Use logical properties in React Native styles:
paddingStartnotpaddingLeftpaddingEndnotpaddingRightmarginStartnotmarginLeftmarginEndnotmarginRight
4. Bidirectional Text Safety
Wrap mixed-script text with <bdi> tags:
<p>User <bdi>{userName}</bdi> posted a comment</p>
5. Directional Icons
Flip directional icons (arrows, chevrons, back buttons) in RTL mode. Non-directional icons (home, settings, search) should NOT be flipped.
6. Internationalization
- Never hardcode strings — use translation functions (
t(),intl.formatMessage()) - Use
Intl.NumberFormatfor numbers and currency - Use
Intl.DateTimeFormatfor dates - Set
dir="auto"ordir="rtl"on root elements
7. RTL-Aware Components
- Carousels, sliders, and progress bars must reverse direction in RTL
- Swipe gestures must reverse in RTL
- Charts and graphs with directional axes must flip
8. Testing
- Always test with
dir="rtl"on the root element - Verify with actual RTL content, not just flipped LTR
Automated RTL Auditing
For automated RTL violation detection and fixing, use rtlify-ai:
npx rtlify-ai init # Install RTL rules
npx rtlify-ai check # Find violations
npx rtlify-ai fix # Auto-fix violations
Related rules
Senior full-stack TypeScript, React, Node.js guidance with clean architecture, testing, and WHY-oriented reasoning.
Quantitative factor research skills for designing, evaluating, and mining alpha factors in equities markets.
Android development with Jetpack Compose, clean architecture, and Material Design 3.
Angular development with Novo Elements UI library using standalone components.
Expert Angular 18 + TypeScript development with Jest, emphasizing clean code and performance.
Manage Kubernetes clusters, add-ons, stacks, and credentials via the Ankra CLI platform.