source: osm/applications/editors/josm/i18n/convpreset.pl@ 12154

Last change on this file since 12154 was 11529, checked in by mfloryan, 16 years ago

Refactoring of JOSM translation infrastructure - translations are now moved away from plugins into separate directory and handled natively in JOSM core. Ant produces josm-translation.jar which if added to core/lib supplies all translations to JOSM core. ("ant install" does that)

File size: 2.2 KB
Line 
1#! /usr/bin/perl -w
2
3# Written by Dirk Stöcker <openstreetmap@dstoecker.de>
4# Public domain, no rights reserved.
5
6use strict;
7
8my $item = "";
9my $group;
10my $comment = 0;
11
12# This is a simple conversion and in no way a complete XML parser
13# but it works with a default Perl installation
14
15while(my $line = <>)
16{
17 chomp($line);
18 if($line =~ /<item\s+name=(".*?")/)
19 {
20 print "tr($1) /* item $item */\n";
21 $item = $group ? "$group$1" : $1;
22 $item =~ s/""/\//;
23 }
24 elsif($line =~ /<group\s+name=(".*?")/)
25 {
26 $group = $1;
27 print "tr($1) /* group $group */\n";
28 }
29 elsif($line =~ /<label\s+text=" "/)
30 {
31 print "/* item $item empty label */\n";
32 }
33 elsif($line =~ /<label\s+text=(".*?")/)
34 {
35 print "tr($1) /* item $item label $1 */\n";
36 }
37 elsif($line =~ /<text.*text=(".*?")/)
38 {
39 my $n = $1;
40 print "tr($n) /* item $item text $n */\n";
41 }
42 elsif($line =~ /<check.*text=(".*?")/)
43 {
44 my $n = $1;
45 print "tr($n) /* item $item check $n */\n";
46 }
47 # first handle display values
48 elsif($line =~ /<combo.*text=(".*?").*display_values="(.*?)"/)
49 {
50 my ($n,$vals) = ($1,$2);
51 print "tr($n) /* item $item combo $n */";
52 foreach my $val (split ",",$vals)
53 {
54 next if $val =~ /^[0-9-]+$/; # search for non-numbers
55 print " tr(\"$val\")";
56 }
57 print "\n";
58 }
59 elsif($line =~ /<combo.*text=(".*?").*values="(.*?)"/)
60 {
61 my ($n,$vals) = ($1,$2);
62 print "tr($n) /* item $item combo $n */";
63 foreach my $val (split ",",$vals)
64 {
65 next if $val =~ /^[0-9-]+$/; # search for non-numbers
66 print " tr(\"$val\")";
67 }
68 print "\n";
69 }
70 elsif($line =~ /<\/group>/)
71 {
72 $group = 0;
73 print "\n";
74 }
75 elsif($line =~ /<\/item>/)
76 {
77 $item = "";
78 print "\n";
79 }
80 elsif($line =~ /^\s*$/
81 || $line =~ /<separator\/>/
82 || $line =~ /<key/
83 || $line =~ /annotations/
84 || $line =~ /<!--/
85 || $line =~ /-->/
86 || $comment)
87 {
88 print "\n";
89 }
90 else
91 {
92 print "/* unparsed line $line */\n";
93 print STDERR "Unparsed line $line\n";
94 }
95
96 # note, these two must be in this order ore oneliners aren't handled
97 $comment = 1 if($line =~ /<!--/);
98 $comment = 0 if($line =~ /-->/);
99}
Note: See TracBrowser for help on using the repository browser.