How to Insert Farsi Words in an English Sentence

Share/Save/Bookmark

LalehGillani
by LalehGillani
26-Mar-2009
 

In my previous blog, I introduced a few tips to help bloggers mix Farsi and English paragraphs in a passage of text. Although these tips were useful, one limitation was not addressed at all:

What if bloggers wish to insert one or more Farsi words inside an English sentence and vice versa? The text formatting is awkward and practically unreadable.

Using the html text editor in Iranian.com site, I was able to manipulate html tags until I could produce such a coveted feature. Here are the required steps:

Mixing Farsi Words with English

Please disable the rich-text first. To mix Farsi words inside an English passage, enter the following on separate lines.

<p align="left">
<span dir="rtl" lang="FA">کورش کبیر</span><br />
<span dir="ltr">is the founding father of our nation. </span><br />
<span dir="rtl" lang="FA">فرزندان کورش </span><br />
<span dir="ltr">showered his resting place with flowers.</span>
< /p>

Mixing English Words with Farsi

Please disable the rich-text first. To mix English words inside a Farsi passage, enter the following on separate lines.

<p align="right">
<span dir="rtl" lang="EN">Korosh Kabir </span><br />
<span dir="rtl">پدر ملت ایران است.</span><br />
<span dir="rtl" lang="EN">Iranians </span><br />
<span dir="rtl">گل به سوی آرامگاه کورش پرتاب کردن. </span>
</p>

The output of the above html code will be the following text:

کورش کبیر
is the founding father of our nation.
فرزندان کورش
showered his resting place with flowers.

Korosh Kabir
پدر ملت ایران است.
His children
گل به سوی آرامگاه کورش پرتاب کردند.

A Brief Description of the Tags:

The span tag provides no visual change by itself. Instead it provides a hook to one part of the text. This hook allows you to add different styles to the content and manipulate the text. The opening and closing paragraph tags mark the beginning and the end of a paragraph respectively. The dir tag sets the direction of the text from right to left or left to right. The lang tag sets the language used for the text immediately following the tag. Valid values are EN for English or FA for Farsi. The br tag stands for break and inserts a line break. Without it, the desired formatting can’t be achieved. You are forewarned!

Happy blogging!

Share/Save/Bookmark

more from LalehGillani
 
LalehGillani

Try This!

by LalehGillani on

If you would like to have a continuous line, please remove the br tag at the end of each line. Doing so will produce the following:

کورش کبیر is the founding father of our nation. فرزندان کورش showered his resting place with flowers to celebrate the Persian New Year.

I realize that it isn't perfect. However, I don't think we are going to get a better text editor any time soon. I hope to be proven wrong.


alborz

Thank you again...

by alborz on

for this additional tip.  It is apparent that to mix the two language fonts one still has to go to a different line.

Best Wishes...

Alborz

PS. JJ has to come up with a better solution though given the users of this site.