I'm creating a website with ASP.net MVC 2.0 which uses two different languages (English and Persian). I want to have two different layouts for these languages, English has a left to right and Persian has a right to left layout.
What came to my mind was, if I could have two different css files, like when you do it with string or image localization will do the work for the site, the problem is I need to know how to do this!
Any other suggestions on how to perform this would be helpful.
Not sure if this is what you ar elooking for, but I did this a few years back in VBScript. Not ideal, but it works for me:
Figure out the language:
Set the style sheet...
I can post more snippets if this is helpful.
You can read about:
In your pages:
alt
); every image with directionality should be reversed (ex: an arrow)class="left"
if you don't want future headaches. Top, bottom, before or after are OK but not left/right (edit:start
andend
are now used in CSS3 to avoid this exact problem of ltr and rtl. May be better than*-before
and*-after
already used for pseudos with colons).text-align
,background-position
,float
,clear
and obviouslyleft
andright
withposition: absolute/relative;
. New CSS3 instructions are to review too (Animations, etc).As noted in the links above, the HTML attribute
dir="rtl"
is used. You'll also need a class (onbody
or some containingdiv
to act like a giant switch for your design needs. LikeThe attribute selector does the same, since IE8 included.
This is the code you can use to get the Locale at the client side. Once you have the locale defined, you can dynamically include a stylesheet in the header.