php class Languages const LANG_DIR secure languages public static func

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
class Languages {
const LANG_DIR = "secure/languages/";
public static function getLanguage($lang = 'Russian') {
return file(self::LANG_DIR . $lang . '.lng');
}
public static function setLanguage($lang = 'Russian') {
$languages = ["Ukrainian", "Russian", "English"];
if(in_array($lang, $languages)) {
$_SESSION['lang'] = $lang;
header('Location: /');
exit;
} else {
$_SESSION['lang'] = isset($_SESSION['lang']) ? $_SESSION['lang'] : 'Russian';
header('Location: /');
exit;
}
}
}