summaryrefslogtreecommitdiffstats
path: root/tdeprint/cups/cupsdconf2/cupsdcomment.pl
blob: b3da5ee7ed84c3de0bc78b9f8fd5ad8c878be03d (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
#!/usr/bin/perl -w
#
# Filter to extract comments for translation from cupsd.conf.template
#
# This code should produce strings identical to tooltips in cupsdcomment.cpp
#
my ($comment_, $example_);
$example_ = "";

load(); # Skip header

while ( <STDIN> )
{
    if(load())
    {
        print toolTip();
    }
}

# Corresponds to Comment::load in cupsdcomment.cpp
sub load
{
    $comment_ = "";
    my($current) = \$comment_;
    while ( <STDIN> )
    {
        if (/^\$\$/)
        {
            $current = \$example_;
        }
        elsif (/^\%\%/)
        {
            next; # Do nothing
        }
        elsif (/^\@\@/)
        {
            return 1;
        }
        elsif (/^[\s]*$/)
        {
            next; # Do nothing
        }
        else
        {
            last if (!/^\#/);
            ${$current} = ${$current} . $_;
        }
    }
    return 0;
}

# Corresponds to Comment::toolTip in cupsdcomment.cpp
sub toolTip
{
    my($str) = $comment_;
    $str =~ s/\"/\\\"/g;
    $str =~ s/^\#[\s]*/i18n\(\"Do not translate the keyword between brackets \(e\.g\. ServerName, ServerAdmin, etc\.\)\",\"/;
    $str =~ s/\n\#[\s]*/\\n\"\n\"/g;
    $str =~ s/\n$/\\n\"\n\)\;\n\n/;
    return $str;
}