blob: 211201e90d2209b38c0cc258bb5537a7b9707fb4 (
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
67
68
69
|
#!/usr/bin/perl
# Post-process the texinfo template to remove some entries which should not be
# translated. Add translator notes to cross references.
use strict;
use warnings;
use Text::Wrap 'wrap';
*OUT = *STDOUT;
if (@ARGV and $ARGV[0] =~ /^-o(.*)/)
{
shift;
my $out = $1 || shift || die "$0: missing output file\n";
open OUT, '>', $out or die "$0: can't open $out ($!)\n";
}
$/ = ''; # read paragraphs
while (<>)
{
# Path name for dir entry. Corrected by fixup-texi-trans.
next if /^#\. type: menuentry/m
and /^msgid "help2man: \(help2man\)"/m;
# "Top" node is special to texinfo.
next if /^#\. type: node/m
and /^msgid "Top"/m;
# Macro commands, and parameters.
next if /^msgid "\@unmacro/m;
next if /^msgid "\\\\text\\\\"/m;
# Options.
next if /^msgid "-[a-zA-Z]"/m;
next if /^msgid "--[a-z-]+"/m;
# Other untranslatable strings.
next if /^#\. type: author/ and /^msgid "[^@]*\@email\{[^}]*\}"/m;
next if /^msgid "help2man"/m;
next if /^msgid "\@url\{[^}]*\}(\\n)?"/m;
next if /^msgid "\@documentencoding UTF-8"/m;
# Find cross references and add a note to translators.
/^msgid "(.*)/sm or next;
my @refs = $1 =~ /\@(?:p?x)?ref\{([^,}]*)\}/g;
if (@refs)
{
for (@refs)
{
s/"\n"//g; # remove line breaks
$_ = qq/"$_",/; # add quotes and comma
}
$refs[-1] =~ s/,$//;
my $plural = '';
if (@refs > 1)
{
$plural = 's';
splice @refs, -1, 0, 'and';
}
my $note = wrap "#. Translators: ", "#. ",
"the translated cross-reference$plural @refs here must match the " .
" target (type: node) translation$plural elsewhere in this file.";
$_ = $note . "\n" . $_;
}
print OUT;
}
|