Matplotlib: Writing right-to-left text (Hebrew, Arabic, etc.)

For Arabic you need both bidi.algorithm.get_display and arabic_reshaper modules: from bidi.algorithm import get_display import matplotlib.pyplot as plt import arabic_reshaper reshaped_text = arabic_reshaper.reshape(u’لغةٌ عربيّة’) artext = get_display(reshaped_text) plt.text(0.25, 0.45, artext , name=”Times New Roman”,fontsize=50) plt.show()

Right-to-Left and Left-to-Right printed nicely

Put a Right-to-Left Embedding character, u’\u202B’, at the beginning of each Hebrew word, and a Pop Directional Formatting character, u’\u202C’, at the end of each word. This will set the Hebrew words apart as RTL sections in an otherwise LTR document. (Note that while this will produce the correct output, you’re also dependent on the … Read more

Twitter Bootstrap Carousel cycle items right to left ( RTL ) reversed

Just override the cycle function with a similar function that calls prev instead of next: $(document).ready(function () { $(‘.carousel’).each(function(){ $(this).carousel(); var carousel = $(this).data(‘bs.carousel’); // or .data(‘carousel’) in bootstrap 2 carousel.pause(); // At first, reverse the order of the items in the carousel because we’re moving backwards $(this).find(‘> .carousel-inner > .item:not(:first-child)’).each(function() { $(this).prependTo(this.parentNode); }); // … Read more

right-to-left languages in Python

Did you try this? http://pypi.python.org/pypi/python-bidi/ http://pypi.python.org/pypi/django-bidi-utils The Israeli FOSS community is doing a lot in this direction. Surprisingly, they happily collaborate also with Farsi speakers 🙂 pyfribidi for windows or any other bidi algorithm

PHP: using DOMDocument whenever I try to write UTF-8 it writes the hexadecimal notation of it

Ok, here you go: $dom = new DOMDocument(‘1.0’, ‘utf-8’); $dom->appendChild($dom->createElement(‘root’)); $dom->documentElement->appendChild(new DOMText(‘ירושלים’)); echo $dom->saveXml(); will work fine, because in this case, the document you constructed will retain the encoding specified as the second argument: <?xml version=”1.0″ encoding=”utf-8″?> <root>ירושלים</root> However, once you load XML into a Document that does not specify an encoding, you will lose … Read more

How to handle RTL languages on pre 4.2 versions of Android?

Sadly, I don’t think there’s a good solution (“good” meaning “does the job and is readily available”). For our own Android apps that support Hebrew, we use a custom rendering mechanism that we developed over many years. The rendering mechanism does everything: proprietary fonts; bidirectional (bidi) analysis; glyph placement; line break analysis; text flow; etc. … Read more