source: osm/applications/editors/josm/i18n/convstyle.pl@ 34775

Last change on this file since 34775 was 31901, checked in by simon04, 9 years ago

JOSM/i18n: get rid of nonsense comments in POT file

This reduces the number of lines in the POT file by 55%.

File size: 1.9 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 $rule_cond; # cumulated conditions from current rule
9
10# This is a simple conversion and in no way a complete XML parser
11# but it works with a default Perl installation
12
13# Print a header to write valid Java code. No line break,
14# so that the input and output line numbers will match.
15print "class trans_style { void tr(String s){} void f() {";
16
17while(my $line = <>)
18{
19 chomp($line);
20 print "tr(\"---DUMMY-MARKER---\"); ";
21 if($line =~ /<rules\s+name=(".*?")/)
22 {
23 print "/* mappaint style named $1 */ tr($1);\n";
24 }
25 elsif($line =~ /<rule\s*>/)
26 {
27 $rule_cond = "";
28 print "/* $line */\n";
29 }
30 elsif($line =~ /<condition.*\s+k="([^"]*)"/)
31 {
32 my $cond_k = $1; # according to schema, k is always present
33 my $cond_v = ($line =~ /\s+v="([^"]*)"/) ? $1 : "";
34 my $cond_b = ($line =~ /\s+b="([^"]*)"/) ? $1 : "";
35 print STDERR "$0: Found both v=\"$cond_v\" and b=\"$cond_b\" for k=\"$cond_k\" at line $.\n" if ($cond_v && $cond_b);
36 my $cond = ($cond_v || $cond_b) ? "$cond_k=$cond_v$cond_b" : "$cond_k"; # v and b shouldn't appear both
37 if ($rule_cond)
38 {
39 $rule_cond .= ", " . $cond;
40 }
41 else
42 {
43 $rule_cond = $cond;
44 }
45 print "/* $line */\n";
46 }
47 elsif($line =~ /colour="([^"]+)#/)
48 {
49 if ($line =~ /\s+colour="([^"]+)#/)
50 {
51 my $c = $1;
52 my $co = $1;
53 $c =~ s/[^a-z0-9]+/./g;
54 print "/* color $co (applied for \"$rule_cond\") */ tr(\"$c\");";
55 }
56 if ($line =~ /\s+dashedcolour="([^"]+)#/)
57 {
58 my $c = $1;
59 my $co = $1;
60 $c =~ s/[^a-z0-9]+/./g;
61 print "/* color $co (applied for \"$rule_cond\") */ tr(\"$c\");";
62 }
63 print "\n";
64 }
65 else
66 {
67 $line =~ s/[ \t]+((?:short)?description) *= *"([^"]+)/*\/ \/* $1 *\/ tr("$2"); \/*/g;
68 print "/* $line */\n";
69 }
70}
71
72print "}}\n";
Note: See TracBrowser for help on using the repository browser.