Enabling ASP.NET site for RTL

I had a question from a friend about how to enable an ASP.NET site for right-to-left languages. I know what needs to be done and I published, over the years, some useful resources and small bit and pieces but I started of with Bing. What did I find? I found many questions from people who would like to enable their ASP .NET site for RTL, but the responses were not very clear. So I thought, this definitely deserves a blog, to clarify what you need to consider to enable your ASP .NET site. So this your brief guide on how to enable your website for RTL (Arabic)

First,  make sure your site is Unicode aware and you are using good fonts that would display properly on any browser. Nice article here The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Second, you need to decide on the resource model that you need to select, either local or global resources. Would you prefer to declare resources implicitly or explicitly.

A good resource for internationalizing your application is available at http://quickstarts.asp.net/QuickStartv20/aspnet/doc/localization/default.aspx

The first two steps are general to any language you need to localize your website into. The next steps are specific to RTL website.

Third, specify when to use the “dir” attribute. The dir attribute handles the RTL direction of text or UI elements.  When direction is specified as RTL (right-to-left) in the <Page> tag, the page will be set as RTL and all the UI elements will be displayed from right to left and the vertical scrollbar appears on the left side, instead on the right. The rest of the controls in the page will implicitly inherit RTL style of the page.

If you don’t want to flip the layout of your page then specify the direction attribute on control s under the page level.

So answer the followings questions:

Where do I need to place the “dir” attribute ?

·         If you want to flip the layout of the page then set “dir=rtl” on the page level

·         If you want to keep your page without the flipping the contents then use the “dir” on the contents and content elements

Some more information at Bidirectional Support for ASP.NET Web Applications

How to load the “dir” on the fly?

Simply save the direction value of your ASP .NET pages in the Arabic Resources and load the resource value on the fly. I have a post to show how to load “dir” on the fly. http://blogs.msdn.com/b/vsarabic/archive/2007/08/27/changing-the-web-page-direction-on-the-fly.aspx

Useful tips and tricks?

Special considerations for the web page alignment and other useful tips and tricks are available in this blog post http://blogs.msdn.com/b/vsarabic/archive/2007/07/31/quick-tips-on-having-arabic-web-pages.aspx

I hope this short guide is useful !

Comments (3)

  1. Isha says:

    Nice one….

  2. www.zeta-resource-editor.com says:

    I recently started making my Zeta Resource Editor work for RTL languages, too. I think I progressed a lot, though I'm not 100 there yet.

  3. Raj says:

    What if I want to place labels to the right side of controls for Arabic Language?!