source: osm/applications/editors/josm/plugins/lang/convpreset.pl@ 9884

Last change on this file since 9884 was 8686, checked in by stoecker, 17 years ago

update to 1328 strings, ca 200 missing

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