Page direction support for ltr/rtl languages
-
hello can you add this function do support right design when change languages from ltr to rtl and vice versa?
// Function to set the direction
function updatePageDirection(language) {
const rtlLanguages = ['ar', 'he', 'fa', 'ur']; // List of RTL language codes
const htmlElement = document.documentElement;
if (rtlLanguages.includes(language)) {
htmlElement.setAttribute('dir', 'rtl'); // Set to RTL
htmlElement.style.direction = 'rtl'; // Optional: Enforce CSS direction
} else {
htmlElement.setAttribute('dir', 'ltr'); // Set to LTR
htmlElement.style.direction = 'ltr'; // Optional: Enforce CSS direction
}
}
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Page direction support for ltr/rtl languages’ is closed to new replies.