File indexing completed on 2024-04-14 04:01:49

0001 #!/usr/bin/perl -W
0002 
0003 use strict;
0004 
0005 for my $file_name ( @ARGV )
0006 {
0007   my $fh;
0008 
0009   unless ( open $fh, "<", $file_name )
0010   {
0011     # warn "Failed to open: '$file_name': $!";
0012     next;
0013   }
0014 
0015   while ( <$fh> )
0016   {
0017     chomp;
0018     if ($_ eq "[cannon]"
0019       || $_ eq "[cavalry]"
0020       || $_ eq "[infantry]"
0021       || $_ eq "[exploding]"
0022       || $_ eq "[firing]"
0023       || $_ eq "[flag]"
0024       || $_ eq "[font]"
0025       || $_ eq "[onu]"
0026       || $_ =~ /\[goal\d+\]/
0027       )
0028     {
0029 #       print "$_: next!\n";
0030       next;
0031     }
0032     elsif ($_ =~ /\[([^\]]*)\]/)
0033     {
0034       print "//i18n: file $file_name line $.\n";
0035       print "// xgettext: no-c-format\n";
0036       print "i18n(\"$1\");\n";
0037     }
0038     elsif ($_ =~ /^(\w+)=(.*)/)
0039     {
0040 #       print "====== $1  =  $2\n";
0041       if ($1 eq "desc" || $1 eq "name")
0042       {
0043         print "//i18n: file $file_name line $.\n";
0044         print "// xgettext: no-c-format\n";
0045         print "i18n(\"$2\");\n";
0046       }
0047       elsif ($1 eq "continents" || $1 eq "countries" || $1 eq "nationalities")
0048       {
0049         my @strings = split ",", $2;
0050         foreach my $str (@strings)
0051         {
0052           print "//i18n: file $file_name line $.\n";
0053           print "// xgettext: no-c-format\n";
0054           print "i18n(\"$str\");\n";
0055         }
0056       }
0057     }
0058     else
0059     {
0060 #       print "unhandled\n";
0061     }
0062   }
0063 }