source: osm/applications/editors/josm/i18n/replacetrans.pl

Last change on this file was 36410, checked in by stoecker, 18 months ago

drop debug

  • Property svn:executable set to *
File size: 981 bytes
RevLine 
[36398]1#! /usr/bin/perl -w
2
3use utf8;
4use strict;
5use open qw/:std :encoding(utf8)/;
[36409]6use Encode;
[36398]7
8# call with pairs of strings, first the wrong string, second the replacement
9# strings must be escaped like in the po-file
10
11my %rep;
12while(@ARGV)
13{
[36409]14 my $from = Encode::decode("utf-8", shift @ARGV);
15 my $to = Encode::decode("utf-8", shift @ARGV);
[36398]16 $rep{$from} = $to;
[36399]17 print "'$from' -> '$to'\n";
[36398]18}
19
[36410]20for my $po (reverse sort glob("po/*.po"))
[36398]21{
22 local $/;
23 $/ = "\n\n";
[36409]24 open my $in,'<:encoding(utf-8)',$po or die;
[36398]25 my $outpo = $po;
26 $outpo =~ s/.*\///;
27 open my $out,'>',$outpo or die;
28 my $changed = 0;
[36409]29
[36398]30 for my $line (<$in>)
31 {
32 $line =~ s/"\n"//g;
33 print $out $line if $line =~ /msgid ""\nmsgstr/;
34 for my $f (keys %rep)
35 {
[36400]36 if($line =~ s/msgid "\Q$f\E"\nmsgstr/msgid "$rep{$f}"\nmsgstr/ && $line !~ /msgstr ""/ && $line !~ /msgstr "$f"/)
[36398]37 {
38 print $out $line;
39 ++$changed;
40 }
41 }
42 }
43 close($out);
44 unlink($outpo) if !$changed;
45}
Note: See TracBrowser for help on using the repository browser.