summaryrefslogtreecommitdiffstats
path: root/tdeui/preparetips
blob: baeaaf3b48832d646bd4a6b72cf4e7d3a7fd4c06 (plain)
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.cpp line $.\n";
		print "i18n(\n";
		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);