File: preparetips

package info (click to toggle)
kde4libs 4:4.14.2-5+deb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 82,428 kB
  • ctags: 99,415
  • sloc: cpp: 761,864; xml: 12,344; ansic: 6,295; java: 4,060; perl: 2,938; yacc: 2,507; python: 1,207; sh: 1,179; ruby: 337; lex: 278; makefile: 29
file content (66 lines) | stat: -rwxr-xr-x 998 bytes parent folder | download | duplicates (10)
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
#! /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";
	}
}

open(FILE,"<","tips") 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: tips:$.\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);