Files
oddmuse/oddtrans

64 lines
1.5 KiB
Plaintext
Raw Normal View History

2004-06-28 21:04:42 +00:00
#!/usr/bin/perl
# Based on umtrans.pl version 1.0 (April 8, 2001) by Clifford Adams.
# Extracts translation strings from wiki script and extensions.
2005-03-06 16:29:44 +00:00
$help = q{
2004-06-28 21:04:42 +00:00
NAME
2004-06-28 22:07:13 +00:00
oddtrans - complement translation tables for Oddmuse
2004-06-28 21:04:42 +00:00
SYNOPSIS
2004-06-28 22:07:13 +00:00
oddtrans [OPTIONS]... [FILE]...
2004-06-28 21:04:42 +00:00
DESCRIPTION
2004-06-28 22:07:13 +00:00
Read all the calls to T(), Ts(), and Tss() from all FILEs, and print
them on standard output, followed by their translation (usually the
empty string unless you use -l to load a library).
2004-06-28 21:04:42 +00:00
2004-06-28 22:07:13 +00:00
-l
2005-03-06 16:29:44 +00:00
load a library from a previous run; you can use multiple -l
2004-06-28 21:04:42 +00:00
EXAMPLES
oddtrans -l german-utf8.pl wiki.pl modules/*.pl > new-german-utf8.pl
2005-03-06 16:29:44 +00:00
};
%Translate = ();
$arg = shift;
while ($arg =~ /^-l/) {
$file = substr($arg, 3);
$file = shift unless $file;
die $help unless -f $file;
%backup = %Translate;
2005-10-07 23:21:14 +00:00
do $file or die "Cannot do $file";
2005-03-06 16:29:44 +00:00
foreach $key (keys %Translate) {
$backup{$key} = $Translate{$key};
}
%Translate = %backup;
$arg = shift;
2004-06-28 21:04:42 +00:00
}
2005-03-06 16:29:44 +00:00
unshift(@ARGV,$arg); # shove the last one back because it is not -l!
2004-06-28 21:04:42 +00:00
2004-06-28 22:07:13 +00:00
my %seen = ();
2004-06-28 21:04:42 +00:00
sub trans {
my ($string) = @_;
my ($result);
$result = '';
$result = $Translate{$string} if (defined($Translate{$string}));
return ' ' if ($seen{$string});
$seen{$string} = 1;
print $string . "\n" . $result . "\n";
return ' ';
}
2005-10-07 23:21:14 +00:00
print '%Translate = split(/\n/,<<END_OF_TRANSLATION);' . "\n";
2004-06-28 21:04:42 +00:00
foreach (<>) {
s/Ts?s?\(\'([^']+)/&trans($1)/ge;
s/Ts?s?\(\"([^"]+)/&trans($1)/ge;
}
print "END_OF_TRANSLATION\n";