Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (54 sloc) 2.005 kb
7418af0 Czech translation
jakubvrana authored
1 <?php
1bc77f8 Report user errors
jakubvrana authored
2 error_reporting(6135); // errors and warnings
0116b9d Don't set cookie in compile scripts
jakubvrana authored
3 unset($_COOKIE["adminer_lang"]);
4 $_SESSION["lang"] = $_SERVER["argv"][1]; // Adminer functions read language from session
5 if (isset($_SESSION["lang"])) {
e1bc7af Change directory structure
jakubvrana authored
6 include dirname(__FILE__) . "/adminer/include/lang.inc.php";
0116b9d Don't set cookie in compile scripts
jakubvrana authored
7 if (isset($_SERVER["argv"][2]) || !isset($langs[$_SESSION["lang"]])) {
ea4fd61 Join translations
jakubvrana authored
8 echo "Usage: php lang.php [lang]\nPurpose: Update adminer/lang/*.inc.php from source code messages.\n";
438ca05 Separate languages
jakubvrana authored
9 exit(1);
10 }
7418af0 Czech translation
jakubvrana authored
11 }
12
430034c Cottage homework
jakubvrana authored
13 $messages_all = array();
ea4fd61 Join translations
jakubvrana authored
14 foreach (array_merge(
15 glob(dirname(__FILE__) . "/adminer/*.php"),
16 glob(dirname(__FILE__) . "/adminer/include/*.php"),
3f5b683 Reintegrate sqlite branch
jakubvrana authored
17 glob(dirname(__FILE__) . "/adminer/drivers/*.php"),
ea4fd61 Join translations
jakubvrana authored
18 glob(dirname(__FILE__) . "/editor/*.php"),
dc05ef6 Remove empty array
jakubvrana authored
19 glob(dirname(__FILE__) . "/editor/include/*.php")
20 ) as $filename) {
ea4fd61 Join translations
jakubvrana authored
21 $file = file_get_contents($filename);
22 if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) { // lang() always uses apostrophes
23 $messages_all += array_combine($matches[1], $matches[2]);
8943678 sprintf() in lang()
jakubvrana authored
24 }
7418af0 Czech translation
jakubvrana authored
25 }
26
0116b9d Don't set cookie in compile scripts
jakubvrana authored
27 foreach (glob(dirname(__FILE__) . "/adminer/lang/" . ($_SESSION["lang"] ? $_SESSION["lang"] : "*") . ".inc.php") as $filename) {
430034c Cottage homework
jakubvrana authored
28 $messages = $messages_all;
16cdb67 Separate Editor translations
jakubvrana authored
29 $file = file_get_contents($filename);
53804a2 @vrana Immunity against CRLF
authored
30 $file = str_replace("\r", "", $file);
16cdb67 Separate Editor translations
jakubvrana authored
31 preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => .*[^,\n]),?~m", $file, $matches, PREG_SET_ORDER);
c645807 PHP 4 compatibility
jakubvrana authored
32 $s = "";
7418af0 Czech translation
jakubvrana authored
33 foreach ($matches as $match) {
34 if (isset($messages[$match[3]])) {
64ba924 Comments
jakubvrana authored
35 // keep current messages
7418af0 Czech translation
jakubvrana authored
36 $s .= "$match[1]$match[2],\n";
37 unset($messages[$match[3]]);
38 } else {
64ba924 Comments
jakubvrana authored
39 // comment deprecated messages
7418af0 Czech translation
jakubvrana authored
40 $s .= "$match[1]// $match[2],\n";
41 }
42 }
8943678 sprintf() in lang()
jakubvrana authored
43 foreach($messages as $idf => $val) {
64ba924 Comments
jakubvrana authored
44 // add new messages
01f52eb Arrays only from %d
jakubvrana authored
45 if ($val == "," && strpos($idf, "%d")) {
438ca05 Separate languages
jakubvrana authored
46 $s .= "\t$idf => array(),\n";
eebf5dc Update translations
jakubvrana authored
47 } elseif (basename($filename) != "en.inc.php") {
ba5220a Update translations
jakubvrana authored
48 $s .= "\t$idf => null,\n";
430034c Cottage homework
jakubvrana authored
49 }
7418af0 Czech translation
jakubvrana authored
50 }
16cdb67 Separate Editor translations
jakubvrana authored
51 $s = "<?php\n\$translations = array(\n$s);\n";
52 if ($s != $file) {
53 fwrite(fopen($filename, "w"), $s); // file_put_contents() since PHP 5
54 echo "$filename updated.\n";
55 }
7418af0 Czech translation
jakubvrana authored
56 }
Something went wrong with that request. Please try again.