-
Notifications
You must be signed in to change notification settings - Fork 1
/
languages.php
101 lines (93 loc) · 2.41 KB
/
languages.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
if(isset($_GET['lang'])) {
$lang = $_GET['lang'];
} else {
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
} else $lang = 'en';
}
require_once("strings.php");
$translates = array(
'en' => $en, // English is default
'cs' => $cs,
);
function tr($string) {
global $lang, $translates;
if($lang == "review") {
global $language_strings;
if(!isset($language_strings[$string]))
array_push($language_strings,$string);
}
if(isset($translates[$lang])) {
$tr = $translates[$lang];
if(isset($tr[$string])) {
echo $tr[$string];
} else echo $string;
} else echo $string;
}
function language_review() {
global $translates,$language_strings;
sort($language_strings);
echo "<div align='center' id='languages'>";
echo "<h1>";
tr("Strings for translation");
echo "</h1>";
echo "<table border=\"1\">";
echo "<tr>";
foreach ($translates as $lang => $strings) {
echo "<th>".$lang."</th>";
}
foreach (array_unique($language_strings) as $string) {
if($string == "") continue;
if(is_numeric($string)) continue;
if(in_array($string,array("st","nd","rd","th"))) continue;
echo "</tr>";
echo "<td>".$string,"</td>";
foreach ($translates as $lang => $strings) {
if($lang != "en") {
echo "<td";
if ($strings[$string] == "") echo " style=\"background: orange;\"";
echo ">".$strings[$string]."</td>";
}
}
echo "</tr>";
}
echo "</table>";
echo "<h1>";
tr("Not used strings");
echo "</h1>";
echo "<table border=\"1\">";
foreach ($translates as $lang => $strings) {
if($lang == "en") continue;
echo "<th>en</th>";
echo "<th>".$lang."</th>";
foreach ($strings as $origin => $string) {
if(in_array($origin,$language_strings)) continue;
echo "<tr>";
echo "<td>".$origin."</td>";
echo "<td>".$string."</td>";
echo "</tr>";
}
}
echo "</table>";
echo "</div>";
echo "<h1>";
tr("PHP export");
echo "</h1>";
echo "<textarea rows=\"".count($language_strings)."\" cols=\"120\">";
foreach ($translates as $lang => $strings) {
if ($lang == "en") continue;
echo "\$$lang = array(\n";
foreach (array_unique($language_strings) as $string) {
if($string == "") continue;
if(is_numeric($string)) continue;
if(in_array($string,array("st","nd","rd","th"))) continue;
echo "\t\"".$string,"\" => \"";
if(isset($strings[$string])) echo $strings[$string];
echo "\",\n";
}
echo ");";
}
echo "</textarea>";
}
?>