5180
|
1 #!/usr/bin/perl -w
|
|
2
|
|
3 # GNOME po update utility.
|
|
4 # (C) 2000 The Free Software Foundation
|
|
5 #
|
|
6 # Author(s): Kenneth Christiansen
|
9531
|
7 # Patches: Björn Voigt <bjoern@cs.tu-berlin.de>
|
5180
|
8
|
|
9
|
|
10 $VERSION = "1.2.5 beta 2";
|
|
11 $LANG = $ARGV[0];
|
|
12 $PACKAGE = "gaim";
|
|
13
|
|
14 if (! $LANG){
|
|
15 print "update.pl: missing file arguments\n";
|
|
16 print "Try `update.pl --help' for more information.\n";
|
|
17 exit;
|
|
18 }
|
|
19
|
|
20 if ($LANG=~/^-(.)*/){
|
|
21
|
|
22 if ("$LANG" eq "--version" || "$LANG" eq "-V"){
|
|
23 print "GNOME PO Updater $VERSION\n";
|
|
24 print "Written by Kenneth Christiansen <kenneth\@gnome.org>, 2000.\n\n";
|
|
25 print "Copyright (C) 2000 Free Software Foundation, Inc.\n";
|
|
26 print "This is free software; see the source for copying conditions. There is NO\n";
|
|
27 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
|
|
28 exit;
|
|
29 }
|
|
30
|
|
31
|
|
32 elsif ($LANG eq "--help" || "$LANG" eq "-H"){
|
|
33 print "Usage: ./update.pl [OPTIONS] ...LANGCODE\n";
|
|
34 print "Updates pot files and merge them with the translations.\n\n";
|
|
35 print " -V, --version shows the version\n";
|
|
36 print " -H, --help shows this help page\n";
|
|
37 print " -P, --pot only generates the potfile\n";
|
|
38 print " -M, --maintain search for missing files in POTFILES.in\n";
|
|
39 print "\nExamples of use:\n";
|
|
40 print "update.sh --pot just creates a new pot file from the source\n";
|
|
41 print "update.sh da created new pot file and updated the da.po file\n\n";
|
|
42 print "Report bugs to <kenneth\@gnome.org>.\n";
|
|
43 exit;
|
|
44 }
|
|
45
|
|
46 elsif($LANG eq "--pot" || "$LANG" eq "-P"){
|
|
47
|
|
48 print "Building the $PACKAGE.pot ...";
|
|
49
|
|
50 $b="xgettext --default-domain\=$PACKAGE --directory\=\.\."
|
|
51 ." --add-comments --keyword\=\_ --keyword\=N\_"
|
|
52 ." --files-from\=\.\/POTFILES\.in ";
|
|
53 $b1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot "
|
|
54 ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)";
|
9531
|
55 print $b . "\n";
|
|
56 if(($ret=system($b . " && " . $b1))==0) {
|
|
57 print "...done\n";
|
|
58 }
|
|
59 else {
|
|
60 print "...failed\n";
|
|
61 }
|
5180
|
62
|
9531
|
63 exit $ret;
|
5180
|
64 }
|
|
65
|
|
66 elsif ($LANG eq "--maintain" || "$LANG" eq "-M"){
|
|
67
|
9531
|
68 $a="find ../ -path ../intl -prune -o -print | egrep '.*\\.(c|y|cc|c++|h|gob)\$' ";
|
5180
|
69
|
|
70 open(BUF2, "POTFILES.in") || die "update.pl: there's not POTFILES.in!!!\n";
|
9531
|
71 print "Searching for missing _(\" \") entries and for deleted files...\n";
|
5180
|
72 open(BUF1, "$a|");
|
|
73
|
|
74
|
|
75 @buf2 = <BUF2>;
|
|
76 @buf1 = <BUF1>;
|
|
77
|
9531
|
78 if (-s "POTFILES.ignore") {
|
5180
|
79 open FILE, "POTFILES.ignore";
|
|
80 while (<FILE>) {
|
9531
|
81 if ($_=~/^[^#]/o) {
|
5180
|
82 push @bup, $_;
|
|
83 }
|
|
84 }
|
|
85 print "POTFILES.ignore found! Ignoring files...\n";
|
|
86 @buf2 = (@bup, @buf2);
|
9531
|
87 }
|
5180
|
88
|
9531
|
89 foreach my $file (@buf1) {
|
|
90 $cmd="xgettext -o - --omit-header --keyword=_ " .
|
|
91 "--keyword=N_ " . $file . " |";
|
|
92 open XGET, $cmd;
|
|
93 if(<XGET>) {
|
|
94 $file = unpack("x3 A*",$file) . "\n";
|
|
95 push @buff1, $file;
|
|
96 }
|
|
97 close XGET;
|
|
98 # open FILE, "<$file";
|
|
99 # while (<FILE>) {
|
|
100 # if ($_=~/_\(\"/o || $_=~/ngettext\(\"/o){
|
|
101 # $file = unpack("x3 A*",$file) . "\n";
|
|
102 # push @buff1, $file;
|
|
103 # last;
|
|
104 # }
|
|
105 # }
|
|
106 }
|
5180
|
107
|
|
108 @bufff1 = sort (@buff1);
|
|
109
|
|
110 @bufff2 = sort (@buf2);
|
|
111
|
|
112 my %in2;
|
|
113 foreach (@bufff2) {
|
9531
|
114 chomp;
|
5180
|
115 $in2{$_} = 1;
|
|
116 }
|
|
117
|
9531
|
118 my %in1;
|
|
119 foreach (@bufff1) {
|
|
120 chomp;
|
|
121 $in1{$_} = 1;
|
|
122 }
|
|
123
|
|
124 foreach (@bufff1) {
|
|
125 chomp;
|
|
126 if (!exists($in2{$_})) {
|
|
127 push @result, $_ . "\n";
|
|
128 }
|
|
129 }
|
|
130
|
|
131 foreach (@bufff2) {
|
|
132 chomp;
|
|
133 if (! -f "../" . $_) {
|
|
134 push @deletedfiles, $_ . "\n";
|
|
135 }
|
|
136 }
|
|
137
|
|
138 foreach (@bufff2) {
|
|
139 if (!exists($in1{$_})) {
|
|
140 push @noi18nfiles, $_ . "\n";
|
|
141 }
|
|
142 }
|
5180
|
143
|
|
144 if(@result){
|
|
145 open OUT, ">POTFILES.in.missing";
|
|
146 print OUT @result;
|
9531
|
147 print "\nHere are the missing files:\n\n", @result, "\n";
|
5180
|
148 print "File POTFILES.in.missing is being placed in directory...\n";
|
|
149 print "Please add the files that should be ignored in POTFILES.ignore\n";
|
|
150 }
|
|
151 else{
|
9531
|
152 unlink("POTFILES.in.missing");
|
|
153 }
|
|
154
|
|
155 if(@deletedfiles){
|
|
156 open OUT, ">POTFILES.in.deleted";
|
|
157 print OUT @deletedfiles;
|
|
158 print "\nHere are the deleted files:\n\n", @deletedfiles, "\n";
|
|
159 print "File POTFILES.in.deleted is being placed in directory...\n";
|
|
160 print "Please delete the files from POTFILES.in or POTFILES.ignore\n";
|
|
161 }
|
|
162 else{
|
|
163 unlink("POTFILES.in.deleted");
|
|
164 }
|
|
165
|
|
166 if(@noi18nfiles){
|
|
167 open OUT, ">POTFILES.in.noi18n";
|
|
168 print OUT @noi18nfiles;
|
|
169 print "\nHere are the files which currently have no i18n strings:\n\n",
|
|
170 @noi18nfiles, "\n";
|
|
171 print "File POTFILES.in.noi18n is being placed in directory...\n";
|
|
172 print "Please delete the files from POTFILES.in or POTFILES.ignore\n";
|
|
173 print "or ignore the files.\n";
|
|
174 }
|
|
175 else{
|
|
176 unlink("POTFILES.in.noi18n");
|
|
177 }
|
|
178
|
|
179 if( ! @result && ! @deletedfiles ) {
|
5180
|
180 print "\nWell, it's all perfect! Congratulation!\n";
|
9531
|
181 }
|
5180
|
182 }
|
|
183
|
|
184
|
|
185 else{
|
|
186 print "update.pl: invalid option -- $LANG\n";
|
|
187 print "Try `update.pl --help' for more information.\n";
|
|
188 }
|
|
189 exit;
|
|
190 }
|
|
191
|
|
192 elsif(-s "$LANG.po"){
|
|
193
|
|
194 print "Building the $PACKAGE.pot ...";
|
|
195
|
|
196 $c="xgettext --default-domain\=$PACKAGE --directory\=\.\."
|
|
197 ." --add-comments --keyword\=\_ --keyword\=N\_"
|
|
198 ." --files-from\=\.\/POTFILES\.in ";
|
|
199 $c1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot "
|
|
200 ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)";
|
|
201
|
9531
|
202 if(($ret=system($c . " && " . $c1))==0) {
|
|
203 print "...done\n";
|
|
204 }
|
|
205 else {
|
|
206 print "...failed\n";
|
|
207 }
|
5180
|
208
|
9531
|
209 if($ret==0) {
|
|
210 print "\nNow merging $LANG.po with $PACKAGE.pot, and creating an updated $LANG.po ...\n";
|
5180
|
211
|
|
212
|
9531
|
213 $d="if msgmerge $LANG.po $PACKAGE.pot -o $LANG.new.po; then " .
|
|
214 " mv -f $LANG.new.po $LANG.po; " .
|
|
215 " msgfmt --statistics -c -v -o /dev/null $LANG.po; " .
|
|
216 "else " .
|
|
217 " echo \"msgmerge failed!\"; " .
|
|
218 " rm -f $LANG.new.po; ".
|
|
219 "fi";
|
5180
|
220
|
9531
|
221 $ret=system($d);
|
5180
|
222
|
9531
|
223 exit $ret;
|
|
224 }
|
5180
|
225 }
|
|
226
|
|
227 else{
|
|
228 print "update.pl: sorry $LANG.po does not exist!\n";
|
|
229 print "Try `update.pl --help' for more information.\n";
|
|
230 exit;
|
|
231 }
|