跳到正文
DEV Community· Itay Cohen·· 2 小時前AI 評分55

希伯來文或阿拉伯文網站 RTL 上線檢查清單:10 個常見問題

RTL QA checklist: 10 things that break when you launch a Hebrew or Arabic version of your site

AI 導讀

作者提供一份希伯來文或阿拉伯文網站的 RTL QA 清單,列出上線時常見的 10 類故障及相應修正方法。清單建議以 CSS 邏輯屬性取代固定的 left/right,並讓電郵、電話、URL 和 ID 號碼輸入欄維持 LTR;另附瀏覽器 Console 掃描腳本,配合桌面及手機畫面作視覺檢查。

正文

Adding dir="rtl" flips the page. It doesn't fix the page. Most RTL bugs come from CSS that was written with "left" and "right" baked in, and from content that mixes directions. Here is the checklist I run on a Hebrew or Arabic page, with the fix for each item.

I built a small test page with deliberate defects to make the examples concrete. Every item below was found on it by a quick scripted pass plus a visual check.

1. dir and lang on the root

<html lang="he" dir="rtl">

Without dir, the browser lays everything out left-to-right. Without lang, screen readers and hyphenation guess. Check this first; it's the cheapest fix.

2. Physical margins and padding

margin-left: auto on a logo pushes it the wrong way once the page is RTL. Use logical properties:

.nav .logo { margin-inline-start: auto; }  /* not margin-left */
.card { margin-inline-end: 20px; }          /* not margin-right */

A quick way to find candidates: search your CSS for left and right in margin, padding, border, left:, right: and float.

3. Floats

float: left stays on the left in RTL, so card order and gutters come out wrong. Prefer flex or grid with gap, or float: inline-start where it's supported.

4. Text alignment

text-align: left inside RTL content looks broken. Use text-align: start.

5. Arrows and directional icons

A "Continue →" arrow points backwards in RTL. Mirror directional icons (arrows, chevrons, "back"/"next") but not logos, media controls or checkmarks:

[dir="rtl"] .icon-chevron { transform: scaleX(-1); }

6. Form fields that must stay LTR

Phone numbers, emails, URLs and ID numbers (Teudat Zehut, for example) should be typed and displayed left-to-right even on an RTL page:

<input type="email" dir="ltr">
<input type="text" inputmode="numeric" dir="ltr" name="id-number">

Keep the label RTL; only the input flips.

7. Mixed-direction text (bidi)

A Hebrew sentence with "iPhone 15 Pro", a price in ₪ and a date can reorder in surprising ways, especially around parentheses and punctuation. Isolate embedded Latin text:

<p>המחיר של <bdi>iPhone 15 Pro</bdi> הוא 4,299 ₪</p>

or unicode-bidi: isolate on the inline element.

8. Fixed widths on mobile

A width: 700px block forces a 700 px layout on a 375 px phone, so the RTL page gets cut off on the right. That's the side where RTL content starts, so it's even worse than in LTR. Use max-width: 100% and test in a mobile viewport.

9. Carousels, sliders and tabs

Swipe direction and "next/previous" controls should follow reading direction. Many slider libraries have an RTL option that's off by default.

10. Numbers, dates and currency

Decide on one format for dates (31/12/2026 vs 2026-12-31) and currency position (₪99.90 vs 99.90 ₪), and apply it consistently. Mixed formats are a common source of "this looks foreign" feedback from native readers.

A 5-minute scripted pass

Paste this in the browser console on an RTL page to list obvious candidates. Treat it as a pointer, not a verdict:

for (const e of document.querySelectorAll('body *')) {
  const cs = getComputedStyle(e);
  if (cs.float === 'left' || cs.float === 'right') console.log('float', cs.float, e);
  if (cs.textAlign === 'left') console.log('text-align:left', e);
}
for (const i of document.querySelectorAll('input[type=email],input[type=tel],input[type=url]'))
  if (getComputedStyle(i).direction === 'rtl') console.log('LTR field rendered RTL', i);

Then do the visual pass: desktop plus a mobile viewport, looking at navigation, forms and any sentence that mixes Hebrew or Arabic with Latin text and numbers.


Disclosure: I offer this as a written QA report with CSS fixes (an AI-assisted review, layout and direction only, not translation): Hebrew/Arabic RTL website QA on Contra. The checklist above works on its own.

來源:DEV Community · dev.to