Arabic and RTL support added

This commit is contained in:
Finix
2026-02-22 19:25:01 +00:00
parent 44834e7d12
commit 30929ee0da
4 changed files with 498 additions and 3 deletions

View File

@@ -12,9 +12,18 @@ const i18n = (() => {
{ code: 'ru-RU', name: 'Russian (Russia)' },
{ code: 'sv-SE', name: 'Swedish (Sweden)' },
{ code: 'tr-TR', name: 'Turkish (Turkey)' },
{ code: 'id-ID', name: 'Indonesian (Indonesia)' }
{ code: 'id-ID', name: 'Indonesian (Indonesia)' },
{ code: 'ar-AR', name: 'Arabic (Saudi Arabia)' }
];
// RTL languages
const rtlLanguages = ['ar-AR'];
// Check if current language is RTL
function isRTL() {
return rtlLanguages.includes(currentLang);
}
// Load single language file
async function loadLanguage(lang) {
if (translations[lang]) return true;
@@ -73,6 +82,24 @@ const i18n = (() => {
const key = el.getAttribute('data-i18n-title');
el.title = t(key);
});
// Update RTL layout
updateRTL();
}
// Update RTL layout
function updateRTL() {
const html = document.documentElement;
const body = document.body;
if (isRTL()) {
html.setAttribute('dir', 'rtl');
html.setAttribute('lang', currentLang);
body.classList.add('rtl');
} else {
html.removeAttribute('dir');
html.setAttribute('lang', currentLang);
body.classList.remove('rtl');
}
}
// Initialize - load saved language only
@@ -88,7 +115,8 @@ const i18n = (() => {
t,
setLanguage,
getAvailableLanguages: () => availableLanguages,
getCurrentLanguage: () => currentLang
getCurrentLanguage: () => currentLang,
isRTL
};
})();