Feature: Sistema multi-idioma con LibreTranslate
- Nuevo includes/i18n.php con funciones t() para traducción - Selector de idioma en navbar y login - Traducciones aplicadas a: dashboard, login, mensajes programados, crear mensaje, sistema - Usa idiomas activados desde admin/languages.php - Caché de traducciones incluido
This commit is contained in:
76
login.php
76
login.php
@@ -2,6 +2,9 @@
|
||||
require_once __DIR__ . '/includes/db.php';
|
||||
require_once __DIR__ . '/includes/env_loader.php';
|
||||
require_once __DIR__ . '/includes/auth.php';
|
||||
require_once __DIR__ . '/includes/i18n.php';
|
||||
|
||||
handleLanguageChange();
|
||||
|
||||
$domain = $_ENV['APP_URL'] ?? getenv('APP_URL') ?? '';
|
||||
if ($domain) {
|
||||
@@ -28,6 +31,8 @@ if (isset($_SESSION['user_id'])) {
|
||||
|
||||
$error = '';
|
||||
$theme = $_COOKIE['theme'] ?? 'light';
|
||||
$currentLang = getCurrentLanguage();
|
||||
$activeLanguages = getActiveLanguages();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$username = $_POST['username'] ?? '';
|
||||
@@ -39,7 +44,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Usuario o contraseña incorrectos';
|
||||
$error = t('Usuario o contraseña incorrectos');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -270,6 +275,45 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
.corner-tr { top: -2px; right: -2px; border-left: none; border-bottom: none; }
|
||||
.corner-bl { bottom: -2px; left: -2px; border-right: none; border-top: none; }
|
||||
.corner-br { bottom: -2px; right: -2px; border-left: none; border-top: none; }
|
||||
|
||||
.lang-selector-login {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.lang-selector-login .btn {
|
||||
background: transparent;
|
||||
border: 1px solid var(--military-green);
|
||||
color: var(--military-sand);
|
||||
border-radius: 0;
|
||||
padding: 4px 10px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.lang-selector-login .btn:hover {
|
||||
background: rgba(61, 74, 50, 0.5);
|
||||
border-color: var(--accent-orange);
|
||||
}
|
||||
|
||||
.lang-selector-login .dropdown-menu {
|
||||
background: var(--military-dark);
|
||||
border: 1px solid var(--military-green);
|
||||
border-radius: 0;
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.lang-selector-login .dropdown-item {
|
||||
color: var(--military-sand);
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.lang-selector-login .dropdown-item:hover,
|
||||
.lang-selector-login .dropdown-item.active {
|
||||
background: rgba(90, 107, 74, 0.4);
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -282,9 +326,29 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<div class="corner-decoration corner-bl"></div>
|
||||
<div class="corner-decoration corner-br"></div>
|
||||
|
||||
<div class="lang-selector-login dropdown">
|
||||
<button class="btn dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
||||
<?php
|
||||
$currentLangData = array_filter($activeLanguages, fn($l) => $l['language_code'] === $currentLang);
|
||||
$currentLangData = reset($currentLangData);
|
||||
if ($currentLang === 'es' || !$currentLangData) {
|
||||
echo '🇲🇽';
|
||||
} else {
|
||||
echo htmlspecialchars($currentLangData['flag_emoji']);
|
||||
}
|
||||
?>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a class="dropdown-item <?= $currentLang === 'es' ? 'active' : '' ?>" href="?lang=es">🇲🇽 <?= t('Español') ?></a></li>
|
||||
<?php foreach ($activeLanguages as $lang): ?>
|
||||
<li><a class="dropdown-item <?= $currentLang === $lang['language_code'] ? 'active' : '' ?>" href="?lang=<?= urlencode($lang['language_code']) ?>"><?= htmlspecialchars($lang['flag_emoji']) ?> <?= t($lang['language_name']) ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="login-header">
|
||||
<div class="login-title">◈ LASTWAR</div>
|
||||
<div class="login-subtitle">Comms Center</div>
|
||||
<div class="login-subtitle"><?= t('Centro de Comunicaciones') ?></div>
|
||||
</div>
|
||||
<div class="login-body">
|
||||
<?php if ($error): ?>
|
||||
@@ -293,15 +357,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
<form method="POST">
|
||||
<div class="mb-4">
|
||||
<label class="form-label">Usuario</label>
|
||||
<input type="text" name="username" class="form-control" placeholder="Ingrese su usuario" required autofocus>
|
||||
<label class="form-label"><?= t('Usuario') ?></label>
|
||||
<input type="text" name="username" class="form-control" placeholder="<?= t('Ingrese su usuario') ?>" required autofocus>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="form-label">Contraseña</label>
|
||||
<label class="form-label"><?= t('Contraseña') ?></label>
|
||||
<input type="password" name="password" class="form-control" placeholder="••••••••" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-login">
|
||||
<i class="bi bi-shield-lock"></i> Acceder
|
||||
<i class="bi bi-shield-lock"></i> <?= t('Acceder') ?>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user