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?
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.