update.pl.in 6.4 KB

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