File indexing completed on 2024-04-14 15:22:18

0001 #! /usr/bin/perl
0002 # little script to extract the text from the tips file
0003 # and output it, so xgettext can add the tips to the po file
0004 #
0005 # 2000 by Matthias Kiefer <matthias.kiefer@gmx.de>
0006 
0007 # IMPORTANT NOTE: Do not change the output without checking if
0008 # translations still work!
0009 
0010 sub printText
0011 {
0012     my $text = $_[0];
0013     
0014     if ( $text cmp "" )
0015     {
0016 
0017     # replace \ with \\
0018     $text =~ s/\\/\\\\/g;
0019 
0020     # replace " with \"
0021     $text =~ s/"/\\"/g;
0022             
0023     print "\"$text\\n\"\n";
0024     }
0025 }
0026 
0027 die "usage: $0 [tips file]" unless defined $ARGV[0];
0028 open(FILE,"<",$ARGV[0]) or die "unable to open tips file";
0029 if ( $^V ge v5.8.0 )
0030 {
0031     binmode(FILE,":utf8");
0032     binmode(STDOUT,":utf8");
0033 }
0034 
0035 $inTip=0;
0036 
0037 while(<FILE>)
0038 {
0039     chomp;
0040 
0041     # tip starts with <html>
0042     if(/^\s*<html>(.*)/io)
0043     {
0044         $inTip=1;
0045         print "// i18n: file: $ARGV[0]:$.\n// i18n: ectx: \@info:tipoftheday\n";
0046         print "i18n(";
0047         printText($1);
0048         next;
0049     }   
0050 
0051     if($inTip!=0)
0052     {
0053         # tip ends with </html>
0054         if(/^(.*)\s*<\/html>/io)
0055         {
0056             printText($1);
0057             print ");\n\n";
0058             $inTip=0;
0059         }
0060         else
0061         {
0062             printText($_);
0063         }
0064     }   
0065 }
0066 
0067 close(FILE);