Bidirectional writing in WordPress

This howto aimed at bloggers wanting to post in more than one language and need bidirectional support. I could not find this info gathered elsewhere, so I'm summarizing what I know here. Distribution license and other info is at the end.

The options I've encountered so far:

1. Open two blogs and "ignore" the problem, like Dr. Gadi Taub and others. There are localized RTL themes ans editions of WordPress in Hebrew (T1 T2), Arabic (T1 T2) and Farsi (T). The maintainer for the Arabic WP is an Israeli, btw.

Pros: No changes in core code, no need for special tricks in themes, sidebar items and other strings are always in the same language as the posts. Mostly Useful if your reader groups are not intersecting.
Cons: You need to keep two installations up to date, backup two databases, match design of seperate themes if you want the same look, and be used to two management interfaces or get used to one of them aligning all the editors and category names the wrong way.
Hint: if you have shell access on the server, you can save some of the double-tasks with symbolic links of plug-ins and such.

2. Start each blog post of the non-default directionality with a manual directionality tag. E.g. if your Theme is in Farsi and you want to post in Italian use <div dir=ltr> or <div style='direction: ltr;'>

Pros: Works in any setup, just paste a tiny string.
Cons: Visual editor may screw this up, doesn't offer a solution to comment directionality, doesn't justify subject and doesn't translate labels in the theme.

3. Yohay at Things.co.il went all out, created two category trees, and hacked his theme to display a post in a directionality based on the post's category's base being English or עברית. cool hack, but I'm too lazy…

4. Hey! the damn COMMENTS are automatically Bidi… When you comment in English on most Hebrew themes and it just shows up right. I remember this used to be a plug-in way back but now I guess Ran has merged it into the code. I wanted to hack that function to flip the posts' bodies and subjects too but could not find it (well, I was just being lazy. didn't look hard enough, I admit…), plus I hate making changes to the core and have them reversedon the next upgrade because I was too lazy to submit them… :)

5. (drum roll) Enter Nadav Elyada's Hebrew4wp! I looked for something like this two weeks ago for Niv Calderon thinking "it's open source, someone MUST have scratched this itch", but I googled in Hebrew… never occured to me It will be published in that other rare language…

So… If your blog's theme is Left-To-Right and you have an occasional post in Hebrew/Farsi/Arabic/Urdu, then hebrew4wp is for you! It will test the first char of every element on the page and change the directionality to RTL based on the UTF-8 value or leave it.

However if you are using an RTL theme and need an occasional post in English, I changed two lines in the Javascript to reverse the effect. Check this out. It works for me, but the hack is so basic it might not do the right thing for everyone. If you find a problem and a nice fix for it, let us know…
This post is…

  • Posted in English so it reaches as many WordPress users as possible, but you are encouraged to translate it.
  • Dedicated to and written in the spirit of Free Software: promoting freedom of speech, cooperation and individual rights and freedoms.
  • Released by me, Ira Abramov, under the CC-sa license with special exception for translators: If you feel certain that Israeli references hurt the propagation of the info in your language/country/community I'll waive you the attribution clause but please drop a comment below with a link to let us know. Feel free to translate it into any language and fix/update as needed. If you have any corrections or additions, please update me and everyone in the comments.
  • Aimed at WordPress at the moment because that's the platform I know best. MovableType issues and other additions are welcome.
  • Aimed especially at my fellow bloggers writing in RTL (Right to left) languages such as Arabic, Farsi, Afghan, Urdu, Uyghur, Yiddish and of course Hebrew.

  • Eager to know If you are posting in rare RTL writing systems like Arameic, Dhivehi, Mende/Ki-ka-ku, N'Ko or Tifinagh. Please drop a link or pingback!
  • Anyone dedicated enough to blog in dead RTL like Etruscan, Meroïtic, Hieroglyphics, Sabaean, Syriac, Nabatean, Oscan, Orkhon, Mandaic, Avestan, Cypriot, Enochian or others – That's very cool! Please comment this post with a link or send a pingback :)
  • Needs multilingual keywords for search engines so help me translate: wordpress, ووردبريس, וורדפרס, bidi, bidirectional, דו-כיווני, LTR, RTL, מימין לשמאל, משמאל לימין, bilingual, דו-לשוני, שתי שפות, Blog, בלוג, posts, מאמרים, כתיבה, help, tip, עזרה, עצות

One Reply to “Bidirectional writing in WordPress”

כתיבת תגובה