Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 62 lines (60 sloc) 2.136 kb
56ac3d18 »
2012-05-25 Mark scripts as executable
1 #!/usr/bin/env php
7418af0c » jakubvrana
2007-07-05 Czech translation
2 <?php
1bc77f88 » jakubvrana
2009-08-28 Report user errors
3 error_reporting(6135); // errors and warnings
0116b9d1 » jakubvrana
2009-09-10 Don't set cookie in compile scripts
4 unset($_COOKIE["adminer_lang"]);
5 $_SESSION["lang"] = $_SERVER["argv"][1]; // Adminer functions read language from session
6 if (isset($_SESSION["lang"])) {
e1bc7af8 » jakubvrana
2009-06-13 Change directory structure
7 include dirname(__FILE__) . "/adminer/include/lang.inc.php";
0116b9d1 » jakubvrana
2009-09-10 Don't set cookie in compile scripts
8 if (isset($_SERVER["argv"][2]) || !isset($langs[$_SESSION["lang"]])) {
ea4fd610 » jakubvrana
2009-07-22 Join translations
9 echo "Usage: php lang.php [lang]\nPurpose: Update adminer/lang/*.inc.php from source code messages.\n";
438ca058 » jakubvrana
2007-07-26 Separate languages
10 exit(1);
11 }
7418af0c » jakubvrana
2007-07-05 Czech translation
12 }
13
430034c3 » jakubvrana
2007-07-09 Cottage homework
14 $messages_all = array();
ea4fd610 » jakubvrana
2009-07-22 Join translations
15 foreach (array_merge(
16 glob(dirname(__FILE__) . "/adminer/*.php"),
17 glob(dirname(__FILE__) . "/adminer/include/*.php"),
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
18 glob(dirname(__FILE__) . "/adminer/drivers/*.php"),
ea4fd610 » jakubvrana
2009-07-22 Join translations
19 glob(dirname(__FILE__) . "/editor/*.php"),
dc05ef62 » jakubvrana
2009-08-21 Remove empty array
20 glob(dirname(__FILE__) . "/editor/include/*.php")
21 ) as $filename) {
ea4fd610 » jakubvrana
2009-07-22 Join translations
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]);
89436789 » jakubvrana
2007-07-09 sprintf() in lang()
25 }
7418af0c » jakubvrana
2007-07-05 Czech translation
26 }
27
0116b9d1 » jakubvrana
2009-09-10 Don't set cookie in compile scripts
28 foreach (glob(dirname(__FILE__) . "/adminer/lang/" . ($_SESSION["lang"] ? $_SESSION["lang"] : "*") . ".inc.php") as $filename) {
430034c3 » jakubvrana
2007-07-09 Cottage homework
29 $messages = $messages_all;
16cdb674 » jakubvrana
2009-07-03 Separate Editor translations
30 $file = file_get_contents($filename);
53804a2c »
2010-10-16 Immunity against CRLF
31 $file = str_replace("\r", "", $file);
6ab272b7 »
2010-10-17 Allow comments in translations
32 preg_match_all("~^(\\s*(?:// [^'].*\\s+)?)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => .*[^,\n]),?~m", $file, $matches, PREG_SET_ORDER);
c6458077 » jakubvrana
2007-08-07 PHP 4 compatibility
33 $s = "";
7418af0c » jakubvrana
2007-07-05 Czech translation
34 foreach ($matches as $match) {
35 if (isset($messages[$match[3]])) {
64ba9242 » jakubvrana
2009-06-21 Comments
36 // keep current messages
7418af0c » jakubvrana
2007-07-05 Czech translation
37 $s .= "$match[1]$match[2],\n";
38 unset($messages[$match[3]]);
39 } else {
64ba9242 » jakubvrana
2009-06-21 Comments
40 // comment deprecated messages
7418af0c » jakubvrana
2007-07-05 Czech translation
41 $s .= "$match[1]// $match[2],\n";
42 }
43 }
6775ac12 »
2010-10-22 Whitespace
44 if ($messages) {
87d617c6 »
2010-11-12 No extra newline for English
45 if (basename($filename) != "en.inc.php") {
46 $s .= "\n";
47 }
6775ac12 »
2010-10-22 Whitespace
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 }
430034c3 » jakubvrana
2007-07-09 Cottage homework
55 }
7418af0c » jakubvrana
2007-07-05 Czech translation
56 }
16cdb674 » jakubvrana
2009-07-03 Separate Editor translations
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 }
7418af0c » jakubvrana
2007-07-05 Czech translation
62 }
Something went wrong with that request. Please try again.