-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlang.php
39 lines (32 loc) · 885 Bytes
/
lang.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
class Lang {
public function Language()
{
static $table = array();
static $loaded = false;
if (!$loaded) {
$loaded = true;
$lang = strtoupper(substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2));
include("settings.php"); //DB Connection
$sql = $MYSQLdb->prepare("SELECT * FROM language");
$sql->execute();
while($print = $sql->fetch(PDO::FETCH_ASSOC))
{
$table[$print["FIELD"]] = $print[$lang];
}
return $table;
} else {
return $table;
}
}
public function Translate($translate)
{
$table = $this->Language();
return $table[$translate];
}
}
$lang = new Lang();
echo $lang->Translate("LOGIN");
echo $lang->Translate("USERNAME");
echo $lang->Translate("PASSWORD");
?>