opt: refine rtl related code

This commit is contained in:
KOWX712
2025-07-26 00:41:36 +08:00
parent 3d9d2843fe
commit 2f5dd03530
8 changed files with 60 additions and 74 deletions

View File

@@ -101,23 +101,8 @@ export async function loadTranslations() {
// Support for rtl language
const isRTL = rtlLang.includes(lang.split('-')[0]);
if (isRTL) {
document.documentElement.setAttribute('dir', 'rtl');
document.documentElement.setAttribute('lang', lang);
// Load extra rtl css
fetch('styles/rtl_styles.css')
.then(res => res.text())
.then(css => {
const style = document.createElement('style');
style.textContent = css;
document.head.appendChild(style);
});
} else {
document.documentElement.setAttribute('dir', 'ltr');
document.documentElement.setAttribute('lang', lang);
}
document.documentElement.setAttribute('dir', isRTL ? 'rtl' : 'ltr');
// Generate language menu
await generateLanguageMenu();
} catch (error) {