4 function po2php_run($argv, $argc) {
7 print "Usage: ".$argv[0]." <file.po>\n\n";
12 $outfile = dirname($pofile)."/strings.php";
14 if (!file_exists($pofile)){
15 print "Unable to find '$pofile'\n";
19 print "Out to '$outfile'\n";
23 $infile = file($pofile);
27 foreach ($infile as $l) {
29 if (substr($l,0,15)=='"Plural-Forms: '){
31 preg_match("|nplurals=([0-9]*); plural=(.*);|", $l, $match);
32 $cond = str_replace('n','$n',$match[2]);
33 $out .= 'function string_plural_select($n){'."\n";
34 $out .= ' return '.$cond.';'."\n";
41 if ($k!="" && substr($l,0,7)=="msgstr "){
42 if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
43 $v = substr($l,7,$len-8);
46 if ($k!="" && substr($l,0,7)=="msgstr["){
47 if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
54 preg_match("|\[([0-9]*)\] (.*)|", $l, $match);
55 $out .= "\t". $match[1]." => ". $match[2] .",\n";
58 if (substr($l,0,6)=="msgid_") { $ink = False; $out .= '$a->strings["'.$k.'"] = '; };
61 $k .= trim($l,"\" \r\n");
62 //$out .= '$a->strings['.$k.'] = ';
65 if (substr($l,0,6)=="msgid "){
66 if ($k!="") $out .= $arr?");\n":";\n";
68 $k = str_replace("msgid ","",$l);
70 $k = trim($k,"\"\r\n");
80 if ($k!="") $out .= $arr?");\n":";\n";
82 file_put_contents($outfile, $out);
86 if (array_search(__file__,get_included_files())===0){
87 po2php_run($argv,$argc);