wiki.pl: Port some fixes from upstream
[Orgmuse.git] / umtrans.pl
blobb95cba01fae1561225c00b86f3f8ee65c786a628
1 #!/usr/bin/perl
2 # umtrans.pl version 1.0 (April 8, 2001)
3 # Extracts translation strings from UseModWiki script.
4 # Run the script with one or two arguments, like:
5 # umtrans.pl wiki.pl > trans.pl
6 # ... creates a new/empty translation table from wiki.pl
7 # umtrans.pl wiki.pl trans.pl > newtrans.pl
8 # ... creates a new translation table using wiki.pl and an old table
10 if ((@ARGV < 1) || (@ARGV > 2)) {
11 # Usage later
12 die("Wrong number of arguments");
15 %Translate = ();
16 if (@ARGV == 2) {
17 do (pop(@ARGV)); # Evaluate second argument and remove it
20 %seen = ();
22 sub trans {
23 my ($string) = @_;
24 my ($result);
25 $result = '';
26 $result = $Translate{$string} if (defined($Translate{$string}));
27 return ' ' if ($seen{$string});
28 $seen{$string} = 1;
29 print $string . "\n" . $result . "\n";
30 return ' ';
33 print '%Translate = split(\'\n\',<<END_OF_TRANSLATION);' . "\n";
34 foreach (<>) {
35 s/Ts?s?\(\'([^']+)/&trans($1)/ge;
36 s/Ts?s?\(\"([^"]+)/&trans($1)/ge;
39 print "END_OF_TRANSLATION\n";