diff --git a/html/database.html b/html/database.html
index 97d42a8..8b56031 100755
--- a/html/database.html
+++ b/html/database.html
@@ -148,6 +148,19 @@
{ id: 'sidebar_mobile', file: 'sidebar.html' }
];
+ let loadedCount = 0;
+ const totalElements = elementsToLoad.length;
+
+ function applyTranslationsWhenReady() {
+ if (typeof i18n !== 'undefined' && i18n.translations && Object.keys(i18n.translations).length > 0) {
+ console.log("Applying translations to dynamically loaded content");
+ i18n.applyTranslations();
+ } else {
+ // Retry after a short delay if translations aren't loaded yet
+ setTimeout(applyTranslationsWhenReady, 100);
+ }
+ }
+
elementsToLoad.forEach(({ id, file }) => {
fetch(file)
.then(response => response.text())
@@ -156,11 +169,22 @@
if (element) {
element.innerHTML = data;
}
+ loadedCount++;
+
+ // Re-apply translations after all dynamic content is loaded
+ if (loadedCount === totalElements) {
+ applyTranslationsWhenReady();
+ }
})
.catch(error => console.error(`Error loading ${file}:`, error));
});
-
+ // Also listen for language change events to re-apply translations
+ document.addEventListener('languageChanged', function() {
+ console.log("Language changed, re-applying translations");
+ i18n.applyTranslations();
+ });
+
});