<?php
class LanguageController {

    public static function loadLanguage() {
        $lang = 'es'; // Idioma por defecto
        if (isset($_SESSION['lang'])) {
            $lang = $_SESSION['lang'];
        }
        require_once __DIR__ . '/../languages/' . $lang . '.php';
        return $lang;
    }

    public static function setLanguage($lang) {
        $_SESSION['lang'] = $lang;
    }
}

if (isset($_GET['action']) && $_GET['action'] == 'set_language') {
    session_start();
    LanguageController::setLanguage($_GET['lang']);
    header("Location: " . $_SERVER['HTTP_REFERER']);
    exit();
}
?>