Merge branch '2067_ruler'
[kaloumi3.git] / po / update.pl
blob234cd3093d62fb607ccd629f0093e9f749999923
1 #!/usr/bin/env perl
2 use warnings;
4 # GNOME po update utility.
5 # (C) 2000 The Free Software Foundation
7 # Author(s): Kenneth Christiansen
10 $VERSION = "1.2.5 beta 2";
11 $LANG = $ARGV[0];
12 $PACKAGE = "mc";
14 if (! $LANG){
15 print "update.pl: missing file arguments\n";
16 print "Try `update.pl --help' for more information.\n";
17 exit;
20 if ($LANG=~/^-(.)*/){
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;
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;
46 elsif($LANG eq "--pot" || "$LANG" eq "-P"){
48 print "Building the $PACKAGE.pot ...";
50 $b="xgettext --default-domain\=$PACKAGE --directory\=\.\."
51 ." --add-comments=TRANSLATORS: --keyword\=\_ --keyword\=N\_"
52 ." --keyword\=Q\_ --files-from\=\.\/POTFILES\.in ";
53 $b1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot "
54 ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)";
56 `$b`;
57 `$b1`;
59 print "...done\n";
61 exit;
64 elsif ($LANG eq "--maintain" || "$LANG" eq "-M"){
66 $a="find ../ -type f -print | egrep '.*\\.(c|y|cc|c++|cxx|cpp|h|gob)\$' ";
68 open(BUF2, "POTFILES.in") || die "update.pl: there is no POTFILES.in !!!\n";
69 print "Searching for missing _(\" \") entries...\n";
70 open(BUF1, "$a|");
73 @buf2 = <BUF2>;
74 @buf1 = <BUF1>;
76 if (-s "POTFILES.ignore"){
77 open FILE, "POTFILES.ignore";
78 while (<FILE>) {
79 if ($_=~/^[^#]/o){
80 push @bup, $_;
83 print "POTFILES.ignore found! Ignoring files...\n";
84 @buf2 = (@bup, @buf2);
87 foreach my $file (@buf1){
88 open FILE, "<$file";
89 while (<FILE>) {
90 if ($_=~/_\s*\(\"/o){
91 $file = unpack("x4 A*",$file) . "\n";
92 push @buff1, $file;
93 last;
98 @bufff1 = sort (@buff1);
100 @bufff2 = sort (@buf2);
102 my %in2;
103 foreach (@bufff2) {
104 $in2{$_} = 1;
107 foreach (@bufff1){
108 if (!exists($in2{$_})){
109 push @result, $_ }
112 if(@result){
113 open OUT, ">POTFILES.in.missing";
114 print OUT @result;
115 print "\nHere are the results:\n\n", @result, "\n";
116 print "File POTFILES.in.missing is being placed in directory...\n";
117 print "Please add the files that should be ignored in POTFILES.ignore\n";
119 else{
120 print "\nWell, it's all perfect! Congratulation!\n";
125 else{
126 print "update.pl: invalid option -- $LANG\n";
127 print "Try `update.pl --help' for more information.\n";
129 exit;
132 elsif(-s "$LANG.po"){
134 print "Building the $PACKAGE.pot ...";
136 $c="xgettext --default-domain\=$PACKAGE --directory\=\.\."
137 ." --add-comments=TRANSLATORS: --keyword\=\_ --keyword\=N\_"
138 ." --keyword\=Q\_ --files-from\=\.\/POTFILES\.in ";
139 $c1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot "
140 ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)";
142 `$c`;
143 `$c1`;
145 print "...done";
147 print "\nNow merging $LANG.po with $PACKAGE.pot, and creating an updated $LANG.po ...\n";
150 $d="mv $LANG.po $LANG.po.old && msgmerge --no-location $LANG.po.old $PACKAGE.pot -o $LANG.po";
152 $f="msgfmt --statistics $LANG.po";
154 `$d`;
155 `$f`;
157 unlink "messages";
158 unlink "$LANG.po.old";
160 exit;
163 else{
164 print "update.pl: sorry, $LANG.po doesn't exist!\n";
165 print "Try `update.pl --help' for more information.\n";
166 exit;