/[eiffelstudio]/trunk/Delivery/studio/lang/script/preference_po_extraction.pl
ViewVC logotype

Diff of /trunk/Delivery/studio/lang/script/preference_po_extraction.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 65624 by tedf, Wed Dec 13 06:22:35 2006 UTC revision 65625 by tedf, Tue Dec 19 09:41:51 2006 UTC
# Line 19  select POT_FILE; Line 19  select POT_FILE;
19  #print "\"Plural-Forms: nplurals=2; plural=n>1;\\n\"\n";  #print "\"Plural-Forms: nplurals=2; plural=n>1;\\n\"\n";
20  #print "\"MIME-Version: 1.0\\n\"\n";  #print "\"MIME-Version: 1.0\\n\"\n";
21  #print "\"Last-Translator: YOUR NAME HERE\\n\"\n\n";  #print "\"Last-Translator: YOUR NAME HERE\\n\"\n\n";
22  while (<DATABASE>) {  while ($line = <DATABASE>) {
23          chomp;          chomp;
24          if (/DESCRIPTION\s*=\s*\"((?:[^"]|\"\")+)\"/i) {          if ($line =~ /DESCRIPTION\s*=\s*\"((?:[^"]|\"\")+)\"/i) {
25                  $_ = $1;                  $extracted = &escape_xml ($1);
26                  s/\"\"/\"/g;                  print "msgid \"$extracted\"\n";
                 s/%N/\\n/g;  
                 s/\&lt\;/</g;  
                 s/\&gt\;/>/g;  
                 s/\&amp\;/&/g;  
                 s/\&apos\;/'/g;  
                 s/\&quot\;/"/g;  
                 print "msgid \"$_\"\n";  
27                  print "msgstr \"\"\n\n";                  print "msgstr \"\"\n\n";
28          }          }
29            if ($line =~ /NAME\s*=\s*\"((?:[^"]|\"\")+)\"/i) {
30                            # A name is in the form of "parent1.parent2.shortname"
31                            # where "parent1.parent2" can be "word1_word2.word3_word4"
32                            # and "shortname" can be "word1_word2_word3".
33                    @spit_parent = split /\./, $1;
34                    foreach $parent (@spit_parent){
35                                    # Follow the algerithm of {PREFERENCES_GRID}.formatted_name
36                                    # to ensure that i18n can find strings extracted.
37                            $words = &upper_case (&make_words ($parent));
38                            print "msgid \"$words\"\n";
39                            print "msgstr \"\"\n\n";
40                    }
41            }
42  }  }
43  select STDOUT;  select STDOUT;
44    
45    sub escape_xml {
46            $_ = $_[0];
47            s/\"\"/\"/g;
48            s/%N/\\n/g;
49            s/\&lt\;/</g;
50            s/\&gt\;/>/g;
51            s/\&amp\;/&/g;
52            s/\&apos\;/'/g;
53            s/\&quot\;/"/g;
54            $_;
55    }
56    
57    sub make_words {
58            $_ = $_[0];
59                    # Replace "_" with space.
60            s/_/ /g;
61            $_;
62    }
63    
64    sub upper_case {
65            $_ = $_[0];
66            s/(.)/\U$1/;
67            $_;
68    }
69    

Legend:
Removed from v.65624  
changed lines
  Added in v.65625

  ViewVC Help
Powered by ViewVC 1.1.23