Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 - -
- - - - - - -

Supporter timezone: Asia/Yerevan (GMT+04:00)

This topic contains 1 reply, has 0 voices.

Last updated by Christopher Amirian 2 weeks ago.

Assisted by: Christopher Amirian.

Author Posts
January 25, 2025 at 2:52 am #16633052

rabeeK

Background of the issue:
I am trying to resolve an issue with the translated language direction (rtl) on my website. I previously submitted another ticket and received assistance from Kor, who was exceptionally helpful. He provided me with the following code to adjust the language direction: *:lang(sy-s) { direction: rtl!important; }. The issue can be seen on this page: hidden link.

Symptoms:
The rtl direction works correctly on pages but there are widgets i am using still reading the wrong direction. When using Firefox, the direction is entirely incorrect. I have cleared caches and tested on different devices, but the issue persists.

Questions:
Could you please conduct a further investigation?

January 26, 2025 at 1:39 pm #16635232

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Welcome to WPML support. Please add the code below to the end of the functions.php file of your theme:

function add_rtl_direction_attribute($output) {
    // Check if the language attribute contains 'sy-s'
    if (strpos($output, 'lang="sy-s"') !== false) {
        // Add the dir="rtl" attribute to the HTML tag
        $output = str_replace('lang="sy-s"', 'lang="sy-s" dir="rtl"', $output);
    }
    return $output;
}

// Hook into the 'language_attributes' filter to modify the HTML tag attributes
add_filter('language_attributes', 'add_rtl_direction_attribute');

The code above will force the dire="rtl" attribute when the sy-s language is shown.

That is an HTML directive to tell your theme to consider the language a right to left one.

The rest will be on your theme's hand how to handle the situation of the RTl language styling.

The snippet above should also work on Firefox.

Thanks.

The topic ‘[Closed] RTL direction’ is closed to new replies.