Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (51 sloc) 1.91 kb
7418af0c » jakubvrana
2007-07-05 Czech translation
1 <?php
31b0572b » jakubvrana
2009-07-03 Don't report E_DEPRECATED
2 error_reporting(4343); // errors and warnings
16cdb674 » jakubvrana
2009-07-03 Separate Editor translations
3 if (isset($_SERVER["argv"][1])) {
b8ef9fb9 » jakubvrana
2009-06-21 Use prefix for cookies
4 $_COOKIE["adminer_lang"] = $_SERVER["argv"][1]; // Adminer functions read language from cookie
e1bc7af8 » jakubvrana
2009-06-13 Change directory structure
5 include dirname(__FILE__) . "/adminer/include/lang.inc.php";
16cdb674 » jakubvrana
2009-07-03 Separate Editor translations
6 if (isset($_SERVER["argv"][2]) || !isset($langs[$_COOKIE["adminer_lang"]])) {
ea4fd610 » jakubvrana
2009-07-22 Join translations
7 echo "Usage: php lang.php [lang]\nPurpose: Update adminer/lang/*.inc.php from source code messages.\n";
438ca058 » jakubvrana
2007-07-26 Separate languages
8 exit(1);
9 }
7418af0c » jakubvrana
2007-07-05 Czech translation
10 }
11
430034c3 » jakubvrana
2007-07-09 Cottage homework
12 $messages_all = array();
ea4fd610 » jakubvrana
2009-07-22 Join translations
13 foreach (array_merge(
14 glob(dirname(__FILE__) . "/adminer/*.php"),
15 glob(dirname(__FILE__) . "/adminer/include/*.php"),
16 glob(dirname(__FILE__) . "/editor/*.php"),
dc05ef62 » jakubvrana
2009-08-21 Remove empty array
17 glob(dirname(__FILE__) . "/editor/include/*.php")
18 ) as $filename) {
ea4fd610 » jakubvrana
2009-07-22 Join translations
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]);
89436789 » jakubvrana
2007-07-09 sprintf() in lang()
22 }
7418af0c » jakubvrana
2007-07-05 Czech translation
23 }
24
ea4fd610 » jakubvrana
2009-07-22 Join translations
25 foreach (glob(dirname(__FILE__) . "/adminer/lang/" . ($_COOKIE["adminer_lang"] ? $_COOKIE["adminer_lang"] : "*") . ".inc.php") as $filename) {
430034c3 » jakubvrana
2007-07-09 Cottage homework
26 $messages = $messages_all;
16cdb674 » jakubvrana
2009-07-03 Separate Editor translations
27 $file = file_get_contents($filename);
28 preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => .*[^,\n]),?~m", $file, $matches, PREG_SET_ORDER);
c6458077 » jakubvrana
2007-08-07 PHP 4 compatibility
29 $s = "";
7418af0c » jakubvrana
2007-07-05 Czech translation
30 foreach ($matches as $match) {
31 if (isset($messages[$match[3]])) {
64ba9242 » jakubvrana
2009-06-21 Comments
32 // keep current messages
7418af0c » jakubvrana
2007-07-05 Czech translation
33 $s .= "$match[1]$match[2],\n";
34 unset($messages[$match[3]]);
35 } else {
64ba9242 » jakubvrana
2009-06-21 Comments
36 // comment deprecated messages
7418af0c » jakubvrana
2007-07-05 Czech translation
37 $s .= "$match[1]// $match[2],\n";
38 }
39 }
89436789 » jakubvrana
2007-07-09 sprintf() in lang()
40 foreach($messages as $idf => $val) {
64ba9242 » jakubvrana
2009-06-21 Comments
41 // add new messages
01f52ebb » jakubvrana
2007-07-10 Arrays only from %d
42 if ($val == "," && strpos($idf, "%d")) {
438ca058 » jakubvrana
2007-07-26 Separate languages
43 $s .= "\t$idf => array(),\n";
eebf5dce » jakubvrana
2009-06-01 Update translations
44 } elseif (basename($filename) != "en.inc.php") {
ba5220ae » jakubvrana
2008-10-27 Update translations
45 $s .= "\t$idf => null,\n";
430034c3 » jakubvrana
2007-07-09 Cottage homework
46 }
7418af0c » jakubvrana
2007-07-05 Czech translation
47 }
16cdb674 » jakubvrana
2009-07-03 Separate Editor translations
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 }
7418af0c » jakubvrana
2007-07-05 Czech translation
53 }
Something went wrong with that request. Please try again.