This post will only be relevant to readers of right-to-left languages, and to developers who develop for such languages. As such, my next post will be a translation of this one into Hebrew.
A bit over a year ago, a friend of mine wrote about embedded unicode right-to-left and left-to-right characters in a flow of text. In a nutshell, when writing text that contains both LTR characters (like English) and RTL characters (like Hebrew), the flow of the text can wind up messed up. Here’s an example:
The (proper) solution to this conundrum is this: wrap your text, which you want flowing in the opposite direction from it’s encapsulating element, in the unicode characters for left-to-right embedding (or right-to-left embedding), and the Pop Directional Formatting character. For further reading, go here.
Back when Liron wrote that post of his, I thought it would be a nice little project to tackle – write a Firefox plugin or Greasemonkey user-script that allows you to encapsulate your text in these characters, for the sake of all those who will follow and read it. I have since then become familiar – and very fond of – bookmarklets. I think a bookmarklet is the best way to distribute the solution to this problem, because it’s lightweight, easy to install and modify, and (at least in theory) cross browser.
Coming to tackle this issue, I knew I needed to insert a string of characters in front of and after the selected text in a textarea. Where have I seen this done before?… Oh, right, right here in WordPress, when I want to make text I’m writing bold or italicized.
With no further ado, I present to you RTL and LTR.
Simply drag those two links to your bookmark toolbar (I actually have a bookmark folder just for bookmarklets), and next time you’re writing bidirectional text, select the wrongly-flowing part, and align it properly.
You can try them out here:
I’d be happy to get feedback on these bookmarklets. They’ve only been tested in Firefox, and I think they will not work in other browsers, seeing how I only used one of the three cross-browser-compatibility parts of the wordpress JS I cannibalized. If they do work in other browsers, or do not work as expected in Firefox, please let me know.
Doesn’t work for me :/