Browse Source

Few translation fixes

svalavuo 5 ngày trước cách đây
mục cha
commit
5a7c996c69
3 tập tin đã thay đổi với 47 bổ sung28 xóa
  1. 6 5
      admin/categories.php
  2. 16 7
      admin/ldap-users.php
  3. 25 16
      public/categories.php

+ 6 - 5
admin/categories.php

@@ -110,11 +110,11 @@ if (isset($_GET['message'])) {
 }
 ?>
 <!DOCTYPE html>
-<html lang="en">
+<html lang="<?php echo Translation::getCurrentLang(); ?>">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Categories - <?php echo SITE_TITLE; ?></title>
+    <title><?php echo t('categories'); ?> - <?php echo SITE_TITLE; ?></title>
     <link rel="stylesheet" href="../css/style.css">
 </head>
 <body>
@@ -133,15 +133,16 @@ if (isset($_GET['message'])) {
                     <a href="logout.php" class="nav-link"><?php echo t('admin_nav_logout'); ?></a>
                 </nav>
                 <div class="user-info">
-                    Welcome, <?php echo htmlspecialchars($user['username']); ?>
+                    <?php echo t('welcome'); ?>, <?php echo htmlspecialchars($user['username']); ?>
                 </div>
+                <?php echo Translation::getLanguageSwitcher('categories.php'); ?>
             </div>
         </header>
 
         <main class="admin-main">
             <div class="page-header">
-                <h2>Categories</h2>
-                <a href="categories.php?action=edit" class="btn btn-primary">Create New Category</a>
+                <h2><?php echo t('categories'); ?></h2>
+                <a href="categories.php?action=edit" class="btn btn-primary"><?php echo t('create_new_category'); ?></a>
             </div>
             
             <?php if ($message): ?>

+ 16 - 7
admin/ldap-users.php

@@ -1,8 +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/auth.php';
 require_once '../includes/ldap.php';
+require_once '../includes/translation.php';
+
+// Translation system is auto-initialized when translation.php is included
 
 $auth = new Auth();
 $auth->requireAuth();
@@ -40,11 +48,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['import_users'])) {
 $user = $auth->getUser();
 ?>
 <!DOCTYPE html>
-<html lang="en">
+<html lang="<?php echo Translation::getCurrentLang(); ?>">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>LDAP Users - <?php echo SITE_TITLE; ?></title>
+    <title><?php echo t('ldap_users'); ?> - <?php echo SITE_TITLE; ?></title>
     <link rel="stylesheet" href="../css/style.css">
 </head>
 <body>
@@ -63,25 +71,26 @@ $user = $auth->getUser();
                     <a href="logout.php" class="nav-link"><?php echo t('admin_nav_logout'); ?></a>
                 </nav>
                 <div class="user-info">
-                    Welcome, <?php echo htmlspecialchars($user['username']); ?>
+                    <?php echo t('welcome'); ?>, <?php echo htmlspecialchars($user['username']); ?>
                 </div>
+                <?php echo Translation::getLanguageSwitcher('ldap-users.php'); ?>
             </div>
         </header>
 
         <main class="admin-main">
-            <h2>LDAP Directory Users</h2>
+            <h2><?php echo t('ldap_directory_users'); ?></h2>
             
             <?php if (isset($_GET['imported'])): ?>
                 <div class="alert alert-success">
-                    <?php echo (int)$_GET['imported']; ?> users imported successfully.
+                    <?php echo (int)$_GET['imported']; ?> <?php echo t('users_imported_successfully'); ?>.
                 </div>
             <?php endif; ?>
 
             <div class="ldap-search">
                 <form method="get" class="search-form">
-                    <input type="text" name="q" placeholder="Search LDAP users..." 
+                    <input type="text" name="q" placeholder="<?php echo t('search_ldap_users_placeholder'); ?>" 
                            value="<?php echo htmlspecialchars($query); ?>">
-                    <button type="submit" class="btn btn-primary">Search</button>
+                    <button type="submit" class="btn btn-primary"><?php echo t('search'); ?></button>
                 </form>
                 
                 <?php if ($ldap->testConnection()): ?>

+ 25 - 16
public/categories.php

@@ -1,7 +1,15 @@
 <?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';
+
+// Translation system is auto-initialized when translation.php is included
 
 $publication = new Publication();
 
@@ -31,11 +39,11 @@ if ($category) {
 $totalPages = ceil($totalPublications / $limit);
 ?>
 <!DOCTYPE html>
-<html lang="en">
+<html lang="<?php echo Translation::getCurrentLang(); ?>">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Categories - <?php echo SITE_TITLE; ?></title>
+    <title><?php echo t('categories'); ?> - <?php echo SITE_TITLE; ?></title>
     <link rel="stylesheet" href="../css/style.css">
 </head>
 <body>
@@ -43,10 +51,11 @@ $totalPages = ceil($totalPublications / $limit);
         <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" class="active">Categories</a>
-                <a href="search.php">Search</a>
+                <a href="index.php"><?php echo t('nav_home'); ?></a>
+                <a href="categories.php" class="active"><?php echo t('nav_categories'); ?></a>
+                <a href="search.php"><?php echo t('nav_search'); ?></a>
             </nav>
+            <?php echo Translation::getLanguageSwitcher('categories.php'); ?>
         </div>
     </header>
 
@@ -54,19 +63,19 @@ $totalPages = ceil($totalPublications / $limit);
         <div class="content-layout">
             <aside class="sidebar">
                 <div class="sidebar-section">
-                    <h3>Search</h3>
+                    <h3><?php echo t('search'); ?></h3>
                     <form method="get" action="search.php" class="search-form">
-                        <input type="text" name="q" placeholder="Search publications...">
-                        <button type="submit" class="btn btn-sm">Search</button>
+                        <input type="text" name="q" placeholder="<?php echo t('search_placeholder'); ?>">
+                        <button type="submit" class="btn btn-sm"><?php echo t('search'); ?></button>
                     </form>
                 </div>
 
                 <div class="sidebar-section">
-                    <h3>Categories</h3>
+                    <h3><?php echo t('categories'); ?></h3>
                     <ul class="category-list">
                         <li>
                             <a href="categories.php" <?php echo empty($currentCategory) ? 'class="active"' : ''; ?>>
-                                All Categories
+                                <?php echo t('all_categories'); ?>
                             </a>
                         </li>
                         <?php foreach ($categories as $cat): ?>
@@ -82,14 +91,14 @@ $totalPages = ceil($totalPublications / $limit);
                 </div>
 
                 <div class="sidebar-section">
-                    <h3>Category Stats</h3>
+                    <h3><?php echo t('category_stats'); ?></h3>
                     <div class="category-stats">
                         <div class="stat-item">
-                            <span class="stat-label">Total Categories:</span>
+                            <span class="stat-label"><?php echo t('total_categories'); ?>:</span>
                             <span class="stat-value"><?php echo count($categories); ?></span>
                         </div>
                         <div class="stat-item">
-                            <span class="stat-label">Total Publications:</span>
+                            <span class="stat-label"><?php echo t('total_publications'); ?>:</span>
                             <span class="stat-value">
                                 <?php echo array_sum(array_column($categories, 'publication_count')); ?>
                             </span>
@@ -102,14 +111,14 @@ $totalPages = ceil($totalPublications / $limit);
                 <div class="page-header">
                     <h2>
                         <?php if ($currentCategory): ?>
-                            Category: <?php echo htmlspecialchars($currentCategory); ?>
+                            <?php echo t('category'); ?>: <?php echo htmlspecialchars($currentCategory); ?>
                         <?php else: ?>
-                            All Categories
+                            <?php echo t('all_categories'); ?>
                         <?php endif; ?>
                     </h2>
                     
                     <?php if ($currentCategory): ?>
-                        <a href="categories.php" class="btn btn-secondary">View All Categories</a>
+                        <a href="categories.php" class="btn btn-secondary"><?php echo t('view_all_categories'); ?></a>
                     <?php endif; ?>
                 </div>