Changeset 28250 in osm for applications/editors/josm/i18n


Ignore:
Timestamp:
2012-04-12T12:31:40+02:00 (12 years ago)
Author:
simon04
Message:

JOSM/i18n: update to handle <list_entry>s

File:
1 edited

Legend:

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

    r26247 r28250  
    99my $group;
    1010my $combo_n;
    11 my @combo_values;
    12 my $combo_idx;
     11my $combo_type;
    1312my $result = 0;
    1413my $comment = 0;
     14my $vctx;
    1515
    1616# This is a simple conversion and in no way a complete XML parser
     
    111111    }
    112112  }
    113   # first handle display values
    114   elsif($line =~ /<(combo|multiselect).*\s+text=(".*?").*\s+display_values="(.*?)"/)
    115   {
    116     my ($type,$n,$vals) = ($1,fix($2),$3);
     113  elsif($line =~ /<(combo|multiselect).*\s+text=(".*?")/)
     114  {
     115    my ($type,$n) = ($1,fix($2));
     116    $combo_n = $n;
     117    $combo_type = $type;
     118    $vctx = ($line =~ /values_context=(".*?")/) ? $1 : undef;
     119    # text
     120    my $tctx = ($line =~ /text_context=(".*?")/) ? $1 : undef;
     121    print "/* item $item $type $n */" . ($tctx ? " trc($tctx, $n);" : " tr($n);");
     122    # display_values / values
    117123    my $sp = ($type eq "combo" ? ",":";");
    118     $combo_n = $n;
    119     $combo_idx = 0;
    120     my $vctx = ($line =~ /values_context=(".*?")/) ? $1 : undef;
    121     if($line =~ /text_context=(".*?")/)
    122     {
    123       print "/* item $item $type $n */ trc($1,$n);";
    124     }
    125     else
    126     {
    127       print "/* item $item $type $n */ tr($n);";
    128     }
    129     $vals =~ s/\\$sp/\x91/g;
    130     @combo_values = split $sp,$vals;
    131     for (my $i=0; $i<@combo_values; ++$i)
    132     {
    133       my $val = $combo_values[$i];
    134       $val =~ s/\x91/$sp/g;
    135       $combo_values[$i] = $val;
    136       next if $val =~ /^[0-9-]+$/; # search for non-numbers
    137       $val = fix($val);
    138       print "/* item $item $type $n display value */" . ($vctx ? " trc($vctx, \"$val\");" : " tr(\"$val\");");
    139     }
    140     print "\n";
    141   }
    142   elsif($line =~ /<(combo|multiselect).*\s+text=(".*?").*\s+values="(.*?)"/)
    143   {
    144     my ($type,$n,$vals) = ($1,fix($2),$3);
    145     my $sp = ($type eq "combo" ? ",":";");
    146     $combo_n = $n;
    147     $combo_idx = 0;
    148     my $vctx = ($line =~ /values_context=(".*?")/) ? $1 : undef;
    149     if($line =~ /text_context=(".*?")/)
    150     {
    151       print "/* item $item $type $n */ trc($1,$n);";
    152     }
    153     else
    154     {
    155       print "/* item $item $type $n */ tr($n);";
    156     }
    157     @combo_values = split $sp,$vals;
    158     foreach my $val (@combo_values)
    159     {
    160       next if $val =~ /^[0-9-]+$/; # search for non-numbers
    161       $val = fix($val);
    162       print "/* item $item $type $n display value */" . ($vctx ? " trc($vctx, \"$val\");" : " tr(\"$val\");");
    163     }
    164     print "\n";
    165   }
    166   elsif(!$comment && $line =~ /<short_description>(.*?)<\/short_description>/)
    167   {
    168     my $n = fix($1);
    169     print "/* item $item combo $combo_n item \"$combo_values[$combo_idx]\" short description */ tr(\"$n\");\n";
    170     $combo_idx++;
     124    my $vals = ($line =~ /display_values="(.*?)"/) ? $1 : ($line =~ /values="(.*?)"/) ? $1 : undef;
     125    if($vals)
     126    {
     127      my @combo_values = split $sp,$vals;
     128      foreach my $val (@combo_values)
     129      {
     130        next if $val =~ /^[0-9-]+$/; # search for non-numbers
     131        $val = fix($val);
     132        print "/* item $item $type $n display value */" . ($vctx ? " trc($vctx, \"$val\");" : " tr(\"$val\");");
     133      }
     134    }
     135    print "\n";
     136  }
     137  elsif(!$comment && $line =~ /<list_entry/)
     138  {
     139    my $vctxi = ($line =~ /value_context=(".*?")/) ? $1 : $vctx;
     140    my $value = ($line =~ /value=(".*?")/) ? $1 : undef;
     141    if($line =~ /display_value=(".*?")/)
     142    {
     143      my $val = fix($1);
     144      print "/* item $item $combo_type $combo_n entry $value display value */" . ($vctxi ? " trc($vctxi, $val);" : " tr($val);") . "\n";
     145    }
     146    else
     147    {
     148      my $val = fix($value);
     149      print "/* item $item $combo_type $combo_n entry $value display value */" . ($vctxi ? " trc($vctxi, $val);" : " tr($val);") . "\n";
     150    }
     151    if($line =~ /short_description=(".*?")/)
     152    {
     153      my $val = fix($1);
     154      print "/* item $item $combo_type $combo_n entry $value short description */ tr($val);\n";
     155    }
    171156  }
    172157  elsif($line =~ /<\/group>/)
     
    183168  {
    184169    $combo_n = "";
    185     $combo_idx = 0;
    186170  }
    187171  elsif(!$line)
Note: See TracChangeset for help on using the changeset viewer.