<?php
if (session_status() === PHP_SESSION_NONE) { session_start(); }

$supported = ['tr','en','es','pt','nl','de','ru','it'];
if (isset($_GET['lang']) && in_array($_GET['lang'], $supported)) {
  $_SESSION['lang'] = $_GET['lang'];
}
$lang = $_SESSION['lang'] ?? 'tr';

$file = __DIR__ . '/../lang/' . $lang . '.php';
if (!file_exists($file)) $file = __DIR__ . '/../lang/tr.php';

$LANG = include $file;

function t($k){ global $LANG; return $LANG[$k] ?? $k; }