Changeset 67

Show
Ignore:
Timestamp:
11/05/07 19:39:57 (2 years ago)
Author:
rcrowley
Message:

Updated the markup-er to take a project name argument.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/uploadr/strings_extract.php

    r54 r67  
    11<? 
     2 
     3        # Get the project name 
     4        if (isset($argv[1])) { 
     5                $project = preg_replace('/[^a-z0-9]/i', '', $argv[1]); 
     6        } else { 
     7                die("Usage: $argv[0] <project> [<locale-path>]\n"); 
     8        } 
     9 
     10        # Get a specific path, if passed 
    211        $dir = dirname(__FILE__); 
    3         $locale = "$dir/MacUploadr.app/Contents/Resources/chrome/locale/en-US"; 
     12        if (isset($argv[2])) { 
     13                $locale = $argv[2]; 
     14        } else { 
     15                $locale = "$dir/MacUploadr.app/Contents/Resources/chrome/locale/en-US"; 
     16        } 
    417 
    518        # 
     
    1528        closedir($dh); 
    1629 
    17         ################################################################################################## 
     30        ############################################################################################## 
    1831 
    1932        function do_dtd($file){ 
    2033 
    21                 global $locale, $str_hash, $dir
     34                global $locale, $str_hash, $dir, $project
    2235 
    2336                $content = implode(file("$locale/$file")); 
     
    2538                $str_hash = array(); 
    2639 
    27                 $content = preg_replace_callback('!ENTITY ([a-z0-9._]+) "([^"]+)"!', 'markup_dtd', $content); 
     40                $content = preg_replace_callback('!ENTITY ([a-z0-9._]+) "([^"]+)"!', 'markup_dtd', 
     41                        $content); 
    2842 
    2943                $content .= "\n\n"; 
     
    3246 
    3347                        $v = implode('{TOKEN}', $v); 
    34                         $content .= "<!ENTITY $k.joined \"<!! dev=\"uploadr3\">$v</!!>\">\n"; 
     48                        $content .= "<!ENTITY $k.joined \"<!! dev=\"$project\">$v</!!>\">\n"; 
    3549                } 
    3650 
    37                 $fh = fopen("$dir/ext_uploadr3_$file.txt", 'w'); 
     51                $fh = fopen("$dir/ext_$project_$file.txt", 'w'); 
    3852                fwrite($fh, $content); 
    3953                fclose($fh); 
    4054 
    41                 echo "wrote $dir/ext_uploadr3_$file.txt\n"; 
     55                echo "wrote $dir/ext_$project_$file.txt\n"; 
    4256        } 
    4357 
    4458        function markup_dtd($m){ 
     59 
     60                global $project; 
    4561 
    4662                if (preg_match('!^(.*)\.(\d+)$!', $m[1], $m2)){ 
     
    5470                } 
    5571 
    56                 return "ENTITY $m[1] \"<!! dev=\"uploadr3\">$m[2]</!!>\""; 
     72                return "ENTITY $m[1] \"<!! dev=\"$project\">$m[2]</!!>\""; 
    5773        } 
    5874 
    59         ################################################################################################## 
     75        ############################################################################################## 
    6076 
    6177        function do_props($file){ 
    6278 
    63                 global $locale, $dir
     79                global $locale, $dir, $project
    6480 
    6581                $content = implode(file("$locale/$file")); 
    6682 
    67                 $content = preg_replace('!^([a-z0-9._]+)=(.*)$!m', "$1=<!! dev=\"uploadr3\">$2</!!>", $content); 
     83                $content = preg_replace('!^([a-z0-9._]+)=(.*)$!m', "$1=<!! dev=\"$project\">$2</!!>", 
     84                        $content); 
    6885 
    69                 $fh = fopen("$dir/ext_uploadr3_$file.txt", 'w'); 
     86                $fh = fopen("$dir/ext_$project_$file.txt", 'w'); 
    7087                fwrite($fh, $content); 
    7188                fclose($fh); 
    7289 
    73                 echo "wrote $dir/ext_uploadr3_$file.txt\n"; 
     90                echo "wrote $dir/ext_$project_$file.txt\n"; 
    7491        } 
    7592 
    76         ################################################################################################## 
     93        ############################################################################################## 
    7794 
    7895?>