3 # GNOME po update utility.
4 # (C) 2000 The Free Software Foundation
6 # Author(s): Kenneth Christiansen
7 # Patches: Björn Voigt <bjoern@cs.tu-berlin.de>
10 $VERSION = "1.2.5 beta 2";
15 print "update.pl: missing file arguments\n";
16 print "Try `update.pl --help' for more information.\n";
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";
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";
46 elsif($LANG eq "--pot" || "$LANG" eq "-P"){
48 print "Building the $PACKAGE.pot ...";
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 \)";
55 if(($ret=system($b . " && " . $b1))==0) {
65 elsif ($LANG eq "--maintain" || "$LANG" eq "-M"){
67 $a="find ../ -path ../intl -prune -o -print | egrep '.*\\.(c|y|cc|c++|h|gob)\$' ";
69 open(BUF2, "POTFILES.in") || die "update.pl: there's not POTFILES.in!!!\n";
70 print "Searching for missing _(\" \") entries and for deleted files...\n";
77 if (-s "POTFILES.ignore") {
78 open FILE, "POTFILES.ignore";
84 print "POTFILES.ignore found! Ignoring files...\n";
85 @buf2 = (@bup, @buf2);
88 foreach my $file (@buf1) {
89 $cmd="xgettext -o - --omit-header --keyword=_ " .
90 "--keyword=N_ " . $file . " |";
93 $file = unpack("x3 A*",$file) . "\n";
97 # open FILE, "<$file";
99 # if ($_=~/_\(\"/o || $_=~/ngettext\(\"/o){
100 # $file = unpack("x3 A*",$file) . "\n";
101 # push @buff1, $file;
107 @bufff1 = sort (@buff1);
109 @bufff2 = sort (@buf2);
125 if (!exists($in2{$_})) {
126 push @result, $_ . "\n";
132 if (! -f "../" . $_) {
133 push @deletedfiles, $_ . "\n";
138 if (!exists($in1{$_})) {
139 push @noi18nfiles, $_ . "\n";
144 open OUT, ">POTFILES.in.missing";
146 print "\nHere are the missing files:\n\n", @result, "\n";
147 print "File POTFILES.in.missing is being placed in directory...\n";
148 print "Please add the files that should be ignored in POTFILES.ignore\n";
151 unlink("POTFILES.in.missing");
155 open OUT, ">POTFILES.in.deleted";
156 print OUT @deletedfiles;
157 print "\nHere are the deleted files:\n\n", @deletedfiles, "\n";
158 print "File POTFILES.in.deleted is being placed in directory...\n";
159 print "Please delete the files from POTFILES.in or POTFILES.ignore\n";
162 unlink("POTFILES.in.deleted");
166 open OUT, ">POTFILES.in.noi18n";
167 print OUT @noi18nfiles;
168 print "\nHere are the files which currently have no i18n strings:\n\n",
170 print "File POTFILES.in.noi18n is being placed in directory...\n";
171 print "Please delete the files from POTFILES.in or POTFILES.ignore\n";
172 print "or ignore the files.\n";
175 unlink("POTFILES.in.noi18n");
178 if( ! @result && ! @deletedfiles ) {
179 print "\nWell, it's all perfect! Congratulation!\n";
185 print "update.pl: invalid option -- $LANG\n";
186 print "Try `update.pl --help' for more information.\n";
191 elsif(-s "$LANG.po"){
193 print "Building the $PACKAGE.pot ...";
195 $c="xgettext --default-domain\=$PACKAGE --directory\=\.\."
196 ." --add-comments --keyword\=\_ --keyword\=N\_"
197 ." --files-from\=\.\/POTFILES\.in ";
198 $c1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot "
199 ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)";
201 if(($ret=system($c . " && " . $c1))==0) {
209 print "\nNow merging $LANG.po with $PACKAGE.pot, and creating an updated $LANG.po ...\n";
212 $d="if msgmerge $LANG.po $PACKAGE.pot -o $LANG.new.po; then " .
213 " mv -f $LANG.new.po $LANG.po; " .
214 " msgfmt --statistics -c -v -o /dev/null $LANG.po; " .
216 " echo \"msgmerge failed!\"; " .
217 " rm -f $LANG.new.po; ".
227 print "update.pl: sorry $LANG.po does not exist!\n";
228 print "Try `update.pl --help' for more information.\n";