Sfoglia il codice sorgente

Fix to translations

svalavuo 5 giorni fa
parent
commit
5df9e15cd0
1 ha cambiato i file con 17 aggiunte e 0 eliminazioni
  1. 17 0
      includes/translation.php

+ 17 - 0
includes/translation.php

@@ -95,18 +95,32 @@ class Translation {
     private function loadTranslations() {
         $langFile = __DIR__ . '/../languages/' . $this->currentLanguage . '.php';
         
+        error_log("Translation: Loading language file: $langFile");
+        error_log("Translation: File exists: " . (file_exists($langFile) ? 'YES' : 'NO'));
+        
         if (file_exists($langFile)) {
             $this->translations = require $langFile;
+            error_log("Translation: Loaded " . count($this->translations) . " translations for {$this->currentLanguage}");
         } else {
             // Fall back to English if current language file doesn't exist
+            error_log("Translation: Falling back to English");
             $fallbackLangFile = __DIR__ . '/../languages/en.php';
             if (file_exists($fallbackLangFile)) {
                 $this->translations = require $fallbackLangFile;
+                error_log("Translation: Loaded " . count($this->translations) . " fallback translations");
+            } else {
+                error_log("Translation: ERROR - English language file not found!");
             }
         }
     }
     
     public function translate($key, $params = []) {
+        // Debug: Check if translations are loaded
+        if (empty($this->translations)) {
+            error_log("Translation: No translations loaded for language: " . $this->currentLanguage);
+            error_log("Translation: Available translations: " . print_r($this->translations, true));
+        }
+        
         if (isset($this->translations[$key])) {
             $translation = $this->translations[$key];
             
@@ -118,6 +132,9 @@ class Translation {
             return $translation;
         }
         
+        // Debug: Log missing translation
+        error_log("Translation: Missing key '$key' for language '{$this->currentLanguage}'");
+        
         // Return key if translation not found
         return $key;
     }