36 lines
1012 B
PHP
36 lines
1012 B
PHP
<?php
|
|
// Définir la langue par défaut
|
|
if (!isset($_SESSION['lang'])) {
|
|
$_SESSION['lang'] = 'ru'; // par défaut russe
|
|
}
|
|
|
|
// Charger le fichier de langue correspondant
|
|
$lang = $_SESSION['lang'];
|
|
$lang_file = __DIR__ . "/../lang/{$lang}.php";
|
|
|
|
// Si le fichier n'existe pas, on repasse en russe
|
|
if (!file_exists($lang_file)) {
|
|
$lang_file = __DIR__ . "/../lang/ru.php";
|
|
}
|
|
|
|
// Charger les traductions
|
|
$translations = require $lang_file;
|
|
|
|
/**
|
|
* Asset helper: ajoute une version ?v= basée sur filemtime()
|
|
* Usage: asset('/includes/custom_style.css')
|
|
*/
|
|
if (!function_exists('asset')) {
|
|
function asset(string $webPath): string
|
|
{
|
|
// Normalise
|
|
if ($webPath === '') return $webPath;
|
|
if ($webPath[0] !== '/') $webPath = '/' . $webPath;
|
|
|
|
$docRoot = rtrim($_SERVER['DOCUMENT_ROOT'] ?? '', '/');
|
|
$fsPath = $docRoot . $webPath;
|
|
|
|
$v = (is_file($fsPath) ? filemtime($fsPath) : time()); // fallback si non trouvé
|
|
return $webPath . '?v=' . $v;
|
|
}
|
|
} |