Skip to content

HTTPS clone URL

Subversion checkout URL

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