desk.pl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/usr/bin/perl -w
  2. # GNOME entry finder utility.
  3. # (C) 2000 The Free Software Foundation
  4. #
  5. # Author(s): Kenneth Christiansen
  6. $VERSION = "1.0.0 beta 5";
  7. $LANG = $ARGV[0];
  8. $OPTION2 = $ARGV[1];
  9. $SEARCH = "Name";
  10. if (! $LANG){
  11. print "desk.pl: missing file arguments\n";
  12. print "Try `desk.pl --help' for more information.\n";
  13. exit;
  14. }
  15. if ($OPTION2){
  16. $SEARCH=$OPTION2;
  17. }
  18. if ($LANG){
  19. if ($LANG=~/^-(.)*/){
  20. if ("$LANG" eq "--version" || "$LANG" eq "-V"){
  21. print "GNOME Entry finder $VERSION\n";
  22. print "Written by Kenneth Christiansen <kenneth\@gnome.org>, 2000.\n\n";
  23. print "Copyright (C) 2000 Free Software Foundation, Inc.\n";
  24. print "This is free software; see the source for copying conditions. There is NO\n";
  25. print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
  26. exit;
  27. }
  28. elsif ($LANG eq "--help" || "$LANG" eq "-H"){
  29. print "Usage: ./desk.pl [OPTIONS] ...LANGCODE ENTRY\n";
  30. print "Checks .desktop and alike files for missing translations.\n\n";
  31. print " -V, --version shows the version\n";
  32. print " -H, --help shows this help page\n";
  33. print "\nReport bugs to <kenneth\@gnome.org>.\n";
  34. exit;
  35. }
  36. else{
  37. print "desk.pl: invalid option -- $LANG\n";
  38. print "Try `desk.pl --help' for more information.\n";
  39. exit;
  40. }
  41. }
  42. else{
  43. $a="find ../ -print | egrep '.*\\.(desktop|soundlist"
  44. ."|directory)' ";
  45. $b="find ../ -print | egrep '.*\\.(desktop|soundlist"
  46. ."|directory)' ";
  47. print "Searching for missing $SEARCH\[$LANG\] entries...\n";
  48. open(BUF1, "$a|");
  49. open(BUF2, "$b|");
  50. @buf1 = <BUF1>;
  51. foreach my $file (@buf1){
  52. open FILE, "<$file";
  53. while (<FILE>) {
  54. if ($_=~/$SEARCH\[$LANG\]\=/o){
  55. $file = unpack("x2 A*",$file) . "\n";
  56. push @buff1, $file;
  57. last;
  58. }
  59. }
  60. }
  61. @buf2 = <BUF2>;
  62. foreach my $file (@buf2){
  63. open FILE, "<$file";
  64. while (<FILE>) {
  65. if ($_=~/$SEARCH\=/o){
  66. $file = unpack("x2 A*",$file) . "\n";
  67. push @buff2, $file;
  68. last;
  69. }
  70. }
  71. }
  72. @bufff1 = sort (@buff1);
  73. @bufff2 = sort (@buff2);
  74. my %in2;
  75. foreach (@bufff1) {
  76. $in2{$_} = 1;
  77. }
  78. foreach (@bufff2){
  79. if (!exists($in2{$_})){
  80. push @result, $_ }
  81. }
  82. }
  83. open(OUT1, ">MISSING.$LANG.$SEARCH");
  84. print OUT1 @result ;
  85. close OUT1;
  86. stat("MISSING.$LANG.$SEARCH");
  87. print "\nWell, you need to fix these:\n\n" if -s _;
  88. print @result if -s _;
  89. print "\nThe list is saved in MISSING.$LANG.$SEARCH\n" if -s _;
  90. print "\nWell, it's all perfect! Congratulation!\n" if -z _;
  91. unlink "MISSING.$LANG.$SEARCH" if -z _;
  92. exit;
  93. }