fix translations
This commit is contained in:
parent
188ac4c400
commit
8f88e85953
|
|
@ -104,7 +104,7 @@ header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 1rem 0;
|
padding: 0.75rem 0;
|
||||||
direction: ltr !important;
|
direction: ltr !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ header {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
color: white;
|
color: white;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 80px;
|
margin-top: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-banner h1 {
|
.page-banner h1 {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ let currentLanguage = 'en';
|
||||||
function toggleLanguage() {
|
function toggleLanguage() {
|
||||||
currentLanguage = currentLanguage === 'en' ? 'ar' : 'en';
|
currentLanguage = currentLanguage === 'en' ? 'ar' : 'en';
|
||||||
|
|
||||||
// Update the language toggle text
|
|
||||||
const langText = document.getElementById('langText');
|
const langText = document.getElementById('langText');
|
||||||
if (langText) {
|
if (langText) {
|
||||||
langText.textContent = currentLanguage === 'en' ? 'EN / عربي' : 'عربي / EN';
|
langText.textContent = currentLanguage === 'en' ? 'EN / عربي' : 'عربي / EN';
|
||||||
|
|
@ -60,15 +59,12 @@ function toggleLanguage() {
|
||||||
// Update text direction for Arabic, excluding header
|
// Update text direction for Arabic, excluding header
|
||||||
if (currentLanguage === 'ar') {
|
if (currentLanguage === 'ar') {
|
||||||
document.documentElement.dir = 'rtl';
|
document.documentElement.dir = 'rtl';
|
||||||
// Add RTL class to main content areas only
|
|
||||||
document.querySelectorAll('main, section, footer').forEach(element => {
|
document.querySelectorAll('main, section, footer').forEach(element => {
|
||||||
element.style.direction = 'rtl';
|
element.style.direction = 'rtl';
|
||||||
});
|
});
|
||||||
// Keep header LTR
|
|
||||||
document.querySelector('header').style.direction = 'ltr';
|
document.querySelector('header').style.direction = 'ltr';
|
||||||
} else {
|
} else {
|
||||||
document.documentElement.dir = 'ltr';
|
document.documentElement.dir = 'ltr';
|
||||||
// Remove RTL from all elements
|
|
||||||
document.querySelectorAll('main, section, footer').forEach(element => {
|
document.querySelectorAll('main, section, footer').forEach(element => {
|
||||||
element.style.direction = 'ltr';
|
element.style.direction = 'ltr';
|
||||||
});
|
});
|
||||||
|
|
@ -82,25 +78,19 @@ function translatePage() {
|
||||||
|
|
||||||
elements.forEach(element => {
|
elements.forEach(element => {
|
||||||
const key = element.getAttribute('data-translate');
|
const key = element.getAttribute('data-translate');
|
||||||
|
|
||||||
// Get translations from all translation files
|
|
||||||
const translations = {
|
|
||||||
...homeTranslations,
|
|
||||||
...aboutTranslations,
|
|
||||||
...workTranslations,
|
|
||||||
...supportTranslations,
|
|
||||||
...contactTranslations
|
|
||||||
};
|
|
||||||
|
|
||||||
// Update text content if translation exists
|
|
||||||
if (translations[currentLanguage] && translations[currentLanguage][key]) {
|
if (translations[currentLanguage] && translations[currentLanguage][key]) {
|
||||||
element.textContent = translations[currentLanguage][key];
|
element.textContent = translations[currentLanguage][key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't automatically translate on page load
|
// Remove onclick attribute from HTML and use event listener
|
||||||
// document.addEventListener('DOMContentLoaded', translatePage);
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const langToggle = document.querySelector('.language-toggle');
|
||||||
// Add click handler to language toggle
|
if (langToggle) {
|
||||||
document.querySelector('.language-toggle').addEventListener('click', toggleLanguage);
|
// Remove existing onclick attribute
|
||||||
|
langToggle.removeAttribute('onclick');
|
||||||
|
// Add click event listener
|
||||||
|
langToggle.addEventListener('click', toggleLanguage);
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue