File: preparetips

package info (click to toggle)
tellico 3.3.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 23,468 kB
  • sloc: cpp: 73,731; xml: 8,383; ansic: 7,003; javascript: 3,059; python: 603; perl: 63; ada: 32; sh: 28; makefile: 22
file content (67 lines) | stat: -rwxr-xr-x 1,057 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /usr/bin/perl
# little script to extract the text from the tips file
# and output it, so xgettext can add the tips to the po file
#
# 2000 by Matthias Kiefer <matthias.kiefer@gmx.de>

# IMPORTANT NOTE: Do not change the output without checking if
# translations still work!

sub printText
{
	my $text = $_[0];
	
	if ( $text cmp "" )
	{

	# replace \ with \\
	$text =~ s/\\/\\\\/g;

	# replace " with \"
	$text =~ s/"/\\"/g;
			
	print "\"$text\\n\"\n";
	}
}

die "usage: $0 [tips file]" unless defined $ARGV[0];
open(FILE,"<",$ARGV[0]) or die "unable to open tips file";
if ( $^V ge v5.8.0 )
{
	binmode(FILE,":utf8");
	binmode(STDOUT,":utf8");
}

$inTip=0;

while(<FILE>)
{
	chomp;

	# tip starts with <html>
	if(/^\s*<html>(.*)/io)
	{
		$inTip=1;
		print "// i18n: file: $ARGV[0]:$.\n// i18n: ectx: \@info:tipoftheday\n";
		print "i18n(";
		printText($1);
		next;
	}	

	if($inTip!=0)
	{
		# tip ends with </html>
		if(/^(.*)\s*<\/html>/io)
		{
			printText($1);
			print ");\n\n";
			$inTip=0;
		}
		else
		{
			printText($_);
		}
	}   
}

close(FILE);