umtrans.pl 1003 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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
  9. if ((@ARGV < 1) || (@ARGV > 2)) {
  10. # Usage later
  11. die("Wrong number of arguments");
  12. }
  13. %Translate = ();
  14. if (@ARGV == 2) {
  15. do (pop(@ARGV)); # Evaluate second argument and remove it
  16. }
  17. %seen = ();
  18. sub trans {
  19. my ($string) = @_;
  20. my ($result);
  21. $result = '';
  22. $result = $Translate{$string} if (defined($Translate{$string}));
  23. return ' ' if ($seen{$string});
  24. $seen{$string} = 1;
  25. print $string . "\n" . $result . "\n";
  26. return ' ';
  27. }
  28. print '%Translate = split(\'\n\',<<END_OF_TRANSLATION);' . "\n";
  29. foreach (<>) {
  30. s/Ts?s?\(\'([^']+)/&trans($1)/ge;
  31. s/Ts?s?\(\"([^"]+)/&trans($1)/ge;
  32. }
  33. print "END_OF_TRANSLATION\n";