Skip to content

HTTPS clone URL

Subversion checkout URL

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