Saturday, May 20, 2006

Arabic content filps too

Hi
In the last Geeks conference in dubai there was a lot about Arabic interface and other Arabic stuff so I will start to add more articles about this issue here.
I will try to start from were they ended in the conference.
We have an interface that support Arabic and English, the web document goes from left to right to right to left when needed.

So what's new, the data itself. Lets assume we had a drop down list that contain some lookup data (ex: Countries list) when we want to change to Arabic the Browser labels and direction change but not the data. So this is the simplest way I found to change the data itself.

In any field that contain strings that is needed in both languages we will add to the column name in the database table (Arabic) and (English) so if we had a table for countries called Countries and contained an ID and a Name field we will rename the Name field to NameEnglish and Add another field with the name NameArabic

Original Table
Countries

Fields
ID
Name

New Table (Multi Language)
Countries
Fields
ID
NameArabic (better to make the field Unicode for example nvarchar(100))
NameEnglish

In the binding filed of the drop down list we will do the following.

If we have the language in the profile
Eval("Name"+Profile.Language.tostring)
The Profile.Language field must contin the word Arabic or English

Or if we have the language in the QueryString:
Eval("Name"+Request.QueryString("Language"))
Note: the query string must contain the string Arabic or the word English

So now not only the interface flips but even the content. This technique can be used in gridview, datalist or any binding context