#!/usr/bin/perl # Based on umtrans.pl version 1.0 (April 8, 2001) by Clifford Adams. # Extracts translation strings from wiki script and extensions. use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; our($opt_l, %Translate); getopts('l:'); do $opt_l if $opt_l; sub VERSION_MESSAGE { my $fh = shift; print $fh '$Id: oddtrans,v 1.2 2004/06/28 22:07:13 as Exp $' . "\n"; } sub HELP_MESSAGE { my $fh = shift; print $fh <<'EOT'; NAME oddtrans - complement translation tables for Oddmuse SYNOPSIS oddtrans [OPTIONS]... [FILE]... DESCRIPTION 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). -l load a library from a previous run EXAMPLES oddtrans -l german-utf8.pl wiki.pl modules/*.pl > new-german-utf8.pl EOT } my %seen = (); 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 ' '; } print '%Translate = split(\'\n\',<) { s/Ts?s?\(\'([^']+)/&trans($1)/ge; s/Ts?s?\(\"([^"]+)/&trans($1)/ge; } print "END_OF_TRANSLATION\n";