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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 65625 - (show annotations)
Tue Dec 19 09:41:51 2006 UTC (13 years, 1 month ago) by tedf
File MIME type: text/plain
File size: 1717 byte(s)
Updated estudio.pot with preference names, language names and others.
Added script to extract names of preference.
1 #!/bin/perl
2 #This script extracts descriptions from default.xml,
3 #and put them into generated preference.pot file.
4
5 unless (open DATABASE, "../../eifinit/default.xml") {
6 die "Error: Couldn't open default.xml: $!; aborting";
7 }
8
9 unless (open POT_FILE, ">>../po_files/estudio.pot") {
10 die "Error: Couldn't open estudio.pot: $!; aborting";
11 }
12
13 select POT_FILE;
14 #print "msgid \"\"\n";
15 #print "msgstr \"\"\n";
16 #print "\"Language-Team: YOUR TEAM HERE\\n\"\n";
17 #print "\"Content-Type: text/plain; charset=UTF-8\\n\"\n";
18 #print "\"Content-Transfer-Encoding: 8bit\\n\"\n";
19 #print "\"Plural-Forms: nplurals=2; plural=n>1;\\n\"\n";
20 #print "\"MIME-Version: 1.0\\n\"\n";
21 #print "\"Last-Translator: YOUR NAME HERE\\n\"\n\n";
22 while ($line = <DATABASE>) {
23 chomp;
24 if ($line =~ /DESCRIPTION\s*=\s*\"((?:[^"]|\"\")+)\"/i) {
25 $extracted = &escape_xml ($1);
26 print "msgid \"$extracted\"\n";
27 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;
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

Properties

Name Value
svn:eol-style native
svn:keywords Author Date ID Revision

  ViewVC Help
Powered by ViewVC 1.1.23