File indexing completed on 2024-04-21 14:54:22

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 # SPDX-FileCopyrightText: 2000 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 open(FILE,"<","tips") or die "unable to open tips file";
0028 if ( $^V ge v5.8.0 )
0029 {
0030     binmode(FILE,":utf8");
0031     binmode(STDOUT,":utf8");
0032 }
0033 
0034 $inTip=0;
0035 
0036 while(<FILE>)
0037 {
0038     chomp;
0039 
0040     # tip starts with <html>
0041     if(/^\s*<html>(.*)/io)
0042     {
0043         $inTip=1;
0044         print "// i18n: file: tips:$.\n// i18n: ectx: \@info:tipoftheday\n";
0045         print "i18n(";
0046         printText($1);
0047         next;
0048     }   
0049 
0050     if($inTip!=0)
0051     {
0052         # tip ends with </html>
0053         if(/^(.*)\s*<\/html>/io)
0054         {
0055             printText($1);
0056             print ");\n\n";
0057             $inTip=0;
0058         }
0059         else
0060         {
0061             printText($_);
0062         }
0063     }   
0064 }
0065 
0066 close(FILE);