Dev.to WebDev 🛠 Dev 👁 0 📖 2 min read

How to make the Shopify Dawn theme work in Arabic (RTL)

Dawn can show Arabic text, but version 16.2.0 does not set a right-to-left direction. Your words are in Arabic while the menu, the cart and the arrows stay laid out for English. Here is how to fix it yourself.

Dawn can show Arabic text, but version 16.2.0 does not set a right-to-left direction. Your words are in Arabic while the menu, the cart and the arrows stay laid out for English. Here is how to fix it yourself.

1. Check that you need this

Open your theme code and look at the first lines of layout/theme.liquid. If the <html> tag already has a dir attribute, as in Horizon, stop here.

2. Set the direction for Arabic only

Duplicate your theme. In layout/theme.liquid, just before </head>, add:

{%- assign lang = request.locale.iso_code | split: '-' | first -%}
{%- if lang == 'ar' -%}
  <script>document.documentElement.setAttribute('dir', 'rtl');</script>
{%- endif -%}

Grids and flexible rows now mirror on their own. That is a good part of the page.

3. Remove letter spacing

Dawn adds space between letters. Arabic letters join, so this cuts words apart.

html[dir='rtl'] body * { letter-spacing: 0 !important; }

4. Fix what does not mirror

Anything written with left or right stays where it was: 541 lines in Dawn 16.2.0. The ones visitors notice first:

  • Drawers. The phone menu slides from the left, the cart from the right. Both need the opposite side.
  • Fields. Labels sit on the left, over the Arabic text.
  • Arrows. Submenu, pagination and carousel arrows point the wrong way.
  • Card text. Its alignment is a theme setting, so it stays on the left.

Example for the cart drawer:

html[dir='rtl'] .drawer__inner { transform: translateX(-100%); }
html[dir='rtl'] .drawer.active .drawer__inner { transform: none; }

5. Check the carousels

In RTL, browsers count horizontal scroll with negative numbers. Dawn's carousel compares positions from the left, so the page counter is wrong (on one theme demo, "3" became "5"). CSS cannot fix this.

6. Keep numbers in order

html[dir='rtl'] .price-item { unicode-bidi: plaintext; }
html[dir='rtl'] input[type='tel'] { direction: ltr; text-align: right; }

7. Test

Go through the store on a phone and a computer: menu, search, filters, product, cart. Then check that English has not changed. A free snippet and a 40-point checklist are here: https://github.com/fadi1008/arabic-rtl-lite-shopify.

I also sell a ready-made kit with the full stylesheet, the carousel fix and Arabic theme texts: https://fadiwave871.gumroad.com/l/arabic-rtl-kit-shopify-dawn. You can do all of it yourself with the steps above.

Independent article, not affiliated with Shopify.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.