~/.netrc option string added
[midnight-commander.git] / po / update.pl
blob48c6ce5f71969240090e6c5dca8076e324b3ff63
1 #!/usr/bin/perl -w
3 # GNOME po update utility.
4 # (C) 2000 The Free Software Foundation
6 # Author(s): Kenneth Christiansen
9 $VERSION = "1.2.5 beta 2";
10 $LANG = $ARGV[0];
11 $PACKAGE = "mc";
13 if (! $LANG){
14 print "update.pl: missing file arguments\n";
15 print "Try `update.pl --help' for more information.\n";
16 exit;
19 if ($LANG=~/^-(.)*/){
21 if ("$LANG" eq "--version" || "$LANG" eq "-V"){
22 print "GNOME PO Updater $VERSION\n";
23 print "Written by Kenneth Christiansen <kenneth\@gnome.org>, 2000.\n\n";
24 print "Copyright (C) 2000 Free Software Foundation, Inc.\n";
25 print "This is free software; see the source for copying conditions. There is NO\n";
26 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
27 exit;
31 elsif ($LANG eq "--help" || "$LANG" eq "-H"){
32 print "Usage: ./update.pl [OPTIONS] ...LANGCODE\n";
33 print "Updates pot files and merge them with the translations.\n\n";
34 print " -V, --version shows the version\n";
35 print " -H, --help shows this help page\n";
36 print " -P, --pot only generates the potfile\n";
37 print " -M, --maintain search for missing files in POTFILES.in\n";
38 print "\nExamples of use:\n";
39 print "update.sh --pot just creates a new pot file from the source\n";
40 print "update.sh da created new pot file and updated the da.po file\n\n";
41 print "Report bugs to <kenneth\@gnome.org>.\n";
42 exit;
45 elsif($LANG eq "--pot" || "$LANG" eq "-P"){
47 print "Building the $PACKAGE.pot ...";
49 $b="xgettext --default-domain\=$PACKAGE --directory\=\.\."
50 ." --add-comments --keyword\=\_ --keyword\=N\_"
51 ." --files-from\=\.\/POTFILES\.in ";
52 $b1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot "
53 ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)";
55 `$b`;
56 `$b1`;
58 print "...done\n";
60 exit;
63 elsif ($LANG eq "--maintain" || "$LANG" eq "-M"){
65 $a="find ../ -type f -print | egrep '.*\\.(c|y|cc|c++|h|gob)' ";
67 open(BUF2, "POTFILES.in") || die "update.pl: there's not POTFILES.in!!!\n";
68 print "Searching for missing _(\" \") entries...\n";
69 open(BUF1, "$a|");
72 @buf2 = <BUF2>;
73 @buf1 = <BUF1>;
75 if (-s "POTFILES.ignore"){
76 open FILE, "POTFILES.ignore";
77 while (<FILE>) {
78 if ($_=~/^[^#]/o){
79 push @bup, $_;
82 print "POTFILES.ignore found! Ignoring files...\n";
83 @buf2 = (@bup, @buf2);
86 foreach my $file (@buf1){
87 open FILE, "<$file";
88 while (<FILE>) {
89 if ($_=~/_\(\"/o){
90 $file = unpack("x3 A*",$file) . "\n";
91 push @buff1, $file;
92 last;
97 @bufff1 = sort (@buff1);
99 @bufff2 = sort (@buf2);
101 my %in2;
102 foreach (@bufff2) {
103 $in2{$_} = 1;
106 foreach (@bufff1){
107 if (!exists($in2{$_})){
108 push @result, $_ }
111 if(@result){
112 open OUT, ">POTFILES.in.missing";
113 print OUT @result;
114 print "\nHere are the results:\n\n", @result, "\n";
115 print "File POTFILES.in.missing is being placed in directory...\n";
116 print "Please add the files that should be ignored in POTFILES.ignore\n";
118 else{
119 print "\nWell, it's all perfect! Congratulation!\n";
124 else{
125 print "update.pl: invalid option -- $LANG\n";
126 print "Try `update.pl --help' for more information.\n";
128 exit;
131 elsif(-s "$LANG.po"){
133 print "Building the $PACKAGE.pot ...";
135 $c="xgettext --default-domain\=$PACKAGE --directory\=\.\."
136 ." --add-comments --keyword\=\_ --keyword\=N\_"
137 ." --files-from\=\.\/POTFILES\.in ";
138 $c1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot "
139 ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)";
141 `$c`;
142 `$c1`;
144 print "...done";
146 print "\nNow merging $LANG.po with $PACKAGE.pot, and creating an updated $LANG.po ...\n";
149 $d="mv $LANG.po $LANG.po.old && msgmerge $LANG.po.old $PACKAGE.pot -o $LANG.po";
151 $f="msgfmt --statistics $LANG.po";
153 `$d`;
154 `$f`;
156 unlink "messages";
157 unlink "$LANG.po.old";
159 exit;
162 else{
163 print "update.pl: sorry $LANG.po does not exist!\n";
164 print "Try `update.pl --help' for more information.\n";
165 exit;