root/trunk/uploadr/strings_extract.php

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

Finished the about dialog, committed strings to the main CVS and updated Cal's script to add .txt to the output files.

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