source: osm/applications/editors/josm/i18n/extract_i18n_newticket.pl@ 36398

Last change on this file since 36398 was 36386, checked in by stoecker, 2 weeks ago

add script to extract translation data for newticket dialog

  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#! /usr/bin/perl -w
2
3use utf8;
4use strict;
5use open qw/:std :encoding(utf8)/;
6
7my %want;
8my $file;
9my $idx = 'a';
10
11open $file,'<','specialmessages.java' or die;
12for my $line (<$file>)
13{
14 if($line =~ /\/\* JOSM trac newticket page \*\/ tr\("(.*)"\);/)
15 {
16 my $res = $1;
17 $want{$res} = $idx++;
18 }
19 close($file);
20}
21for my $po (reverse sort glob("po/*.po"))
22{
23 local $/;
24 $/ = "\n\n";
25 open $file,'<',$po or die;
26 my %lang;
27
28 for my $line (<$file>)
29 {
30 $line =~ s/"\n"//g;
31 next if $line =~ /# fuzzy/;
32 for my $t (keys %want)
33 {
34 if($line =~ /msgid "\Q$t\E"/ && $line =~ /msgstr "(.+)"/)
35 {
36 my $res = $1;
37 $res =~ s/\\"/"/g;
38 $res =~ s/''/’/g;
39 $res =~ s/'/’/g;
40 $lang{$want{$t}} = $res;
41 }
42 }
43 }
44 if(scalar(%lang) == scalar(%want))
45 {
46 $po =~ /^po\/(.*)\.po$/;
47 my $code = $1;
48 if($code =~ /en_/)
49 {
50 my $diff = 0;
51 for my $t (sort keys %lang)
52 {
53 my %wantr = reverse %want;
54 my $r = $lang{$t};
55 $r =~ s/\"/\\"/g;
56 if($wantr{$t} ne $r)
57 {
58 ++$diff;
59 }
60 }
61 next if !$diff;
62 print "$diff\n";
63 }
64 print " } else if (navigator.language.indexOf('$code') == 0) {\n";
65 for my $t (sort keys %lang)
66 {
67 print " $t = '$lang{$t}';\n";
68 }
69 }
70}
Note: See TracBrowser for help on using the repository browser.