Changeset 26180 in osm for applications/editors


Ignore:
Timestamp:
2011-06-25T23:37:12+02:00 (13 years ago)
Author:
stoecker
Message:

support ' in preset data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/i18n/convpreset.pl

    r25155 r26180  
    2121print "class trans_preset { void tr(String s){} void f() {";
    2222
     23sub fix($)
     24{
     25  my ($val) = @_;
     26  $val =~ s/'/''/g;
     27  return $val;
     28}
     29
    2330while(my $line = <>)
    2431{
     
    2633  if($line =~ /<item\s+name=(".*?")/)
    2734  {
    28     my $val = $1;
     35    my $val = fix($1);
    2936    $item = $group ? "$group$val" : $val;
    3037    $item =~ s/""/\//;
     
    4047  elsif($line =~ /<group.*\s+name=(".*?")/)
    4148  {
    42     my $gr = $1;
     49    my $gr = fix($1);
    4350    $group = $group ? "$group$gr" : $gr;
    4451    $group =~ s/\"\"/\//;
     
    5865  elsif($line =~ /<label.*\s+text=(".*?")/)
    5966  {
    60     my $text = $1;
     67    my $text = fix($1);
    6168    if($line =~ /text_context=(".*?")/)
    6269    {
     
    7077  elsif($line =~ /<text.*\s+text=(".*?")/)
    7178  {
    72     my $n = $1;
     79    my $n = fix($1);
    7380    if($line =~ /text_context=(".*?")/)
    7481    {
     
    8289  elsif($line =~ /<check.*\s+text=(".*?")/)
    8390  {
    84     my $n = $1;
     91    my $n = fix($1);
    8592    if($line =~ /text_context=(".*?")/)
    8693    {
     
    94101  elsif($line =~ /<role.*\s+text=(".*?")/)
    95102  {
    96     my $n = $1;
     103    my $n = fix($1);
    97104    if($line =~ /text_context=(".*?")/)
    98105    {
     
    107114  elsif($line =~ /<(combo|multiselect).*\s+text=(".*?").*\s+display_values="(.*?)"/)
    108115  {
    109     my ($type,$n,$vals) = ($1,$2,$3);
     116    my ($type,$n,$vals) = ($1,fix($2),$3);
    110117    my $sp = ($type eq "combo" ? ",":";");
    111118    $combo_n = $n;
     
    122129    $vals =~ s/\\$sp/\x91/g;
    123130    @combo_values = split $sp,$vals;
    124     for (my $i=0; $i<@combo_values; ++$i) {
    125       $combo_values[$i] =~ s/\x91/$sp/g;
    126       next if $combo_values[$i] =~ /^[0-9-]+$/; # search for non-numbers
    127       print "/* item $item $type $n display value */" . ($vctx ? " trc($vctx, \"$combo_values[$i]\");" : " tr(\"$combo_values[$i]\");");
     131    for (my $i=0; $i<@combo_values; ++$i)
     132    {
     133      my $val = $combo_values[$i];
     134      $val =~ s/\x91/$sp/g;
     135      next if $val =~ /^[0-9-]+$/; # search for non-numbers
     136      $val = fix($val);
     137      print "/* item $item $type $n display value */" . ($vctx ? " trc($vctx, \"$val\");" : " tr(\"$val\");");
    128138    }
    129139    print "\n";
     
    131141  elsif($line =~ /<(combo|multiselect).*\s+text=(".*?").*\s+values="(.*?)"/)
    132142  {
    133     my ($type,$n,$vals) = ($1,$2,$3);
     143    my ($type,$n,$vals) = ($1,fix($2),$3);
    134144    my $sp = ($type eq "combo" ? ",":";");
    135145    $combo_n = $n;
     
    148158    {
    149159      next if $val =~ /^[0-9-]+$/; # search for non-numbers
     160      $val = fix($val);
    150161      print "/* item $item $type $n display value */" . ($vctx ? " trc($vctx, \"$val\");" : " tr(\"$val\");");
    151162    }
     
    154165  elsif(!$comment && $line =~ /<short_description>(.*?)<\/short_description>/)
    155166  {
    156     my $n = $1;
     167    my $n = fix($1);
    157168    print "/* item $item combo $combo_n item \"$combo_values[$combo_idx]\" short description */ tr(\"$n\");\n";
    158169    $combo_idx++;
Note: See TracChangeset for help on using the changeset viewer.