Debian Codegraph @

src/preparetips5

raw
1 #! /usr/bin/perl
2 # little script to extract the text from the tips file
3 # and output it, so xgettext can add the tips to the po file
4 #
5 # SPDX-FileCopyrightText: 2000 Matthias Kiefer <[email protected]>
6
7 # IMPORTANT NOTE: Do not change the output without checking if
8 # translations still work!
9
10 sub printText
11 {
12 my $text = $_[0];
13
14 if ( $text cmp "" )
15 {
16
17 # replace \ with \\
18 $text =~ s/\\/\\\\/g;
19
20 # replace " with \"
21 $text =~ s/"/\\"/g;
22
23 print "\"$text\\n\"\n";
24 }
25 }
26
27 open(FILE,"<","tips") or die "unable to open tips file";
28 if ( $^V ge v5.8.0 )
29 {
30 binmode(FILE,":utf8");
31 binmode(STDOUT,":utf8");
32 }
33
34 $inTip=0;
35
36 while(<FILE>)
37 {
38 chomp;
39
40 # tip starts with <html>
41 if(/^\s*<html>(.*)/io)
42 {
43 $inTip=1;
44 print "// i18n: file: tips:$.\n// i18n: ectx: \@info:tipoftheday\n";
45 print "i18n(";
46 printText($1);
47 next;
48 }
49
50 if($inTip!=0)
51 {
52 # tip ends with </html>
53 if(/^(.*)\s*<\/html>/io)
54 {
55 printText($1);
56 print ");\n\n";
57 $inTip=0;
58 }
59 else
60 {
61 printText($_);
62 }
63 }
64 }
65
66 close(FILE);