root/trunk/uploadr/strings_extract.php

Revision 90, 1.8 kB (checked in by rcrowley, 2 years ago)

Bug in extracter fixed.

Line 
1 <?
2
3     # Aaaand back to the way it was
4     $dir = dirname(__FILE__);
5     $locale = "$dir/MacUploadr.app/Contents/Resources/chrome/locale/en-US";
6
7     #
8     # find files we care about
9     #
10
11     $dh = opendir($locale);
12     while (($file = readdir($dh)) !== false){
13
14         if (preg_match('!\.dtd!', $file)){ do_dtd($file); }
15         if (preg_match('!\.properties!', $file)){ do_props($file); }
16     }
17     closedir($dh);
18
19     ##############################################################################################
20
21     function do_dtd($file){
22
23         global $locale, $str_hash, $dir, $project;
24
25         $content = implode(file("$locale/$file"));
26
27         $str_hash = array();
28
29         $content = preg_replace_callback('!ENTITY ([a-z0-9._]+) "([^"]+)"!', 'markup_dtd',
30             $content);
31
32         $content .= "\n\n";
33
34         foreach ($str_hash as $k => $v){
35
36             $v = implode('{TOKEN}', $v);
37             $content .= "<!ENTITY $k.joined \"<!! dev=\"uploadr3\">$v</!!>\">\n";
38         }
39
40         $fh = fopen("$dir/ext_uploadr3_{$file}.txt", 'w');
41         fwrite($fh, $content);
42         fclose($fh);
43
44         echo "wrote $dir/ext_uploadr3_{$file}.txt\n";
45     }
46
47     function markup_dtd($m){
48
49         global $project;
50
51         if (preg_match('!^(.*)\.(\d+)$!', $m[1], $m2)){
52
53             if ($m2[2] < 10){
54
55                 $GLOBALS[str_hash][$m2[1]][$m2[2]] = $m[2];
56
57                 return "ENTITY $m[1] \"$m[2]\"";
58             }
59         }
60
61         return "ENTITY $m[1] \"<!! dev=\"uploadr3\">$m[2]</!!>\"";
62     }
63
64     ##############################################################################################
65
66     function do_props($file){
67
68         global $locale, $dir, $project;
69
70         $content = implode(file("$locale/$file"));
71
72         $content = preg_replace('!^([a-z0-9._]+)=(.*)$!m', "$1=<!! dev=\"uploadr3\">$2</!!>",
73             $content);
74
75         $fh = fopen("$dir/ext_uploadr3_{$file}.txt", 'w');
76         fwrite($fh, $content);
77         fclose($fh);
78
79         echo "wrote $dir/ext_uploadr3_{$file}.txt\n";
80     }
81
82     ##############################################################################################
83
84 ?>
85
Note: See TracBrowser for help on using the browser.