svalavuo 5 дней назад
Родитель
Сommit
297060c926
2 измененных файлов с 17 добавлено и 24 удалено
  1. 0 17
      includes/translation.php
  2. 17 7
      public/publication.php

+ 0 - 17
includes/translation.php

@@ -95,32 +95,18 @@ 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];
             
@@ -132,9 +118,6 @@ 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;
     }

+ 17 - 7
public/publication.php

@@ -1,7 +1,16 @@
 <?php
+// Start session for language preference
+if (session_status() === PHP_SESSION_NONE) {
+    session_start();
+}
+
 require_once '../includes/config.php';
 require_once '../includes/database.php';
 require_once '../includes/publication.php';
+require_once '../includes/translation.php';
+
+// Initialize translation system
+$translation = Translation::getInstance();
 
 $publication = new Publication();
 
@@ -10,8 +19,8 @@ $pub = $publication->getById($id);
 
 if (!$pub || $pub['status'] !== 'published') {
     http_response_code(404);
-    echo '<h1>Publication Not Found</h1>';
-    echo '<p>The requested publication could not be found.</p>';
+    echo '<h1>' . t('error_publication_not_found') . '</h1>';
+    echo '<p>' . t('error_publication_not_found_description') . '</p>';
     exit;
 }
 
@@ -41,10 +50,11 @@ if ($pub['categories_array']) {
         <div class="container">
             <h1><a href="index.php"><?php echo SITE_TITLE; ?></a></h1>
             <nav class="main-nav">
-                <a href="index.php">Home</a>
-                <a href="categories.php">Categories</a>
-                <a href="search.php">Search</a>
+                <a href="index.php"><?php echo t('nav_home'); ?></a>
+                <a href="categories.php"><?php echo t('nav_categories'); ?></a>
+                <a href="search.php"><?php echo t('nav_search'); ?></a>
             </nav>
+            <?php echo $translation->getLanguageSwitcher('publication.php?id=' . $id); ?>
         </div>
     </header>
 
@@ -87,7 +97,7 @@ if ($pub['categories_array']) {
 
         <?php if (!empty($relatedPublications)): ?>
             <section class="related-publications">
-                <h2>Related Publications</h2>
+                <h2><?php echo t('related_publications'); ?></h2>
                 <div class="publication-grid">
                     <?php foreach ($relatedPublications as $related): ?>
                         <article class="publication-card">
@@ -112,7 +122,7 @@ if ($pub['categories_array']) {
         <?php endif; ?>
 
         <div class="publication-actions">
-            <a href="index.php" class="btn">Back to Publications</a>
+            <a href="index.php" class="btn"><?php echo t('back_to_publications'); ?></a>
         </div>
     </div>