i18n · CSS
RTL and Multi-Language: Think Start/End Instead of Left/Right
What I learned building a store that supports Turkish, English and Arabic (RTL included) and this portfolio: RTL is not a mirror switch. If you write CSS with logical properties from the start, it comes almost for free.
01. Direction is a language setting
Making direction part of the language definition is the cleanest route. In this site's i18n setup each locale declares its direction: Turkish, English and Russian are ltr, Arabic is rtl. The <html dir> attribute changes with the selected language and the CSS reacts to it.
locales: [
{ code: 'tr', language: 'tr-TR', dir: 'ltr', file: 'tr-TR.json' },
{ code: 'en', language: 'en-US', dir: 'ltr', file: 'en.json' },
{ code: 'ar', language: 'ar-SA', dir: 'rtl', file: 'ar-SA.json' },
{ code: 'ru', language: 'ru-RU', dir: 'ltr', file: 'ru.json' }
]
02. start/end instead of left/right
The most common mistake is leaning on physical directions like ml-4, pr-2, left-3, text-left. In RTL they end up on the wrong side. Tailwind has logical counterparts: ms-4/me-4 (margin start/end), ps-10/pe-4 (padding), start-3/end-3 (position), text-start.
The magnifier icon in a search box belongs on the left in LTR and on the right in RTL. Writing start-3 instead of left-3 removes the need for a separate RTL rule.
<!-- Physical: breaks in RTL -->
<input class="pl-10 pr-4">
<Icon class="absolute left-3">
<!-- Logical: flips on its own when direction changes -->
<input class="ps-10 pe-4">
<Icon class="absolute start-3">
03. Where it is not enough: space-x and the rtl: variant
Tailwind's space-x-* utilities work in the physical direction. In the header's menu and buttons you need rtl:space-x-reverse next to them. Using gap-* instead is both simpler and direction-independent.
Some things really do need to change direction: arrow icons (→ should become ← in RTL) and scroll/animation direction. Those need an explicit flip with the rtl: variant.
04. Fonts and mixed content
Arabic needs its own font, but Latin text must not be affected. The way is unicode-range: Noto Sans Arabic only covers the Arabic range, Latin characters stay in Poppins. So a sentence containing both Arabic and "Nuxt" does not get its fonts fighting.
Testing note: when the language changes, not just the text but the layout changes too. This site has separate Playwright tests for /ar paths; RTL bugs are the easiest to spot by eye, but also the quickest to come back in a regression.