Hello everyone
I am Working within React v8.2.2
I want to change the orientation of the entire website - from right to left - when selecting the Arabic language
If you return to the English language, change the direction from left to right
Thank you all
In Angular documentation
There is a page about the RTL Version and how to work on it
But in the React documentation there is no information about RTL Version
I modified the code in the file "Metronici18n.tsx" to look like this
----------------- CODE -----------------
function getConfig(): Props {
const ls = localStorage.getItem(I18N_CONFIG_KEY)
if (ls) {
try {
const lang = JSON.parse(ls) as Props
if(lang.selectedLang === 'ar') {
document.documentElement.lang = "ar";
document.documentElement.dir = "rtl";
console.log("arabic RTL")
}
else if(lang.selectedLang === 'tr') {
document.documentElement.lang = "tr";
document.documentElement.dir = "ltr";
console.log("TurkiÅ LTR")
}
else if(lang.selectedLang === 'en') {
//document.getElementsByClassName('app-navbar-item').item.
document.documentElement.lang = "en";
document.documentElement.dir = "ltr";
console.log("English LTR")
}
return JSON.parse(ls) as Props
} catch (er) {
console.error(er)
}
}
//Arabic is the default language
document.documentElement.lang = "ar"
document.documentElement.dir = "rtl"
return initialState
}
-----------------END CODE -----------------
But I could not move the Sidebar to the right side
There is also a problem in implementing the aforementioned observation
data-kt-menu-placement="bottom-start" => data-kt-menu-placement="bottom-end"
data-kt-menu-placement="right-start" => data-kt-menu-placement="left-start"
When changing languages
Hi,
Unfortunately, dynamic direction switching is currently not supported by Metronic React version.
The only way to change the direction dynamically in our React version is by updating the link href of the main style file. To achieve this, follow the steps below:
import "./_metronic/assets/sass/style.scss"
thank you very much...
it work but There is a simple modification in the “theme-switch-funcions.tsx” file. In “setLtrMode” function
The replacement should be like thisreplace(“style.bundle.rtl.css”, “style.bundle.css”));
Hi,
Thank you for pointing out this mistake I have already updated the gist file.
I am glad to hear that it worked for you. Please let us know if you have any additional questions on this topic or anything else.
Regards,
Lauris Stepanovs,
Keenthemes Support Team