Simple method for changing website styles for rtl languages

When I installed elgg 1.8.8, I tried to use in with rtl language. I noticed that no strightforward method exists in forums and q&a websites and etc., I know two solution explined here: one is only for 1.8- versions and one another is not compatible with all themes. It is a temporary solution (but if you see this topic, thank you Susan for posting this solution when no other solution had exist yet!).

So here is my solution for this problem. It works with language selector as well.

0- I apologize for my poor english!

1- open {Elgg_root}/views/default/page/default.php

2- change '<body>' to this:

<body style="direction: <?php echo((get_current_language='fa' || get_current_language='ar' || blabla) ? 'rtl' : 'ltr'); ?>">

note: 'blabla' stands for other left to right languages. ;)

3- (optional) go to each theme you wish and add [dir='rtl'] block to favorite css codes.

Best Regards

  • Hi Jalal, thanks for this update, i'll check it out in the next few days. Would be excellent if an ltr rtl solution could be incorporated into the language selector plugin

  • Hi Susan,

    There is a more professional solution for this problem. I will post it as soon as possible too. Thank you for your attention.

  • Oh! I corrected my wrong code. I do apologize (== instead of =)

    :

    <body style="direction: <?php echo((get_current_language() == 'fa' || get_current_language() == 'ar' || blabla) ? 'rtl' : 'ltr'); ?>">

  • Even for more usability in stylesheets you can do it for HTML tag:

    <html ... dir="<?php echo(get_current_language() == 'fa' ? 'rtl' : 'ltr'); ?>">

    Then, in css files you can do something like:

     

    .{class_name}

    {

            #your styles for ltr languages 

    }

    html[dir="rtl"] .{class_name}

    {

            #your styles for rtl languages

    }

     

    for example, exchange right padding and left paddings when is necessary.