Changeset 30180 in osm for applications/editors


Ignore:
Timestamp:
2014-01-04T17:11:29+01:00 (11 years ago)
Author:
holgermappt
Message:

New language added. i18n update.

Location:
applications/editors/josm/plugins/photoadjust
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/photoadjust/README

    r30130 r30180  
    1111to place photos that don't have GPS coordinates associated with them
    1212on the map, thus to geotag them.
     13
     14
     15See i18n/README for plugin translation.
    1316
    1417
     
    4548               licence applicable to JOSM (GPL v2 or any later version),
    4649        see https://help.launchpad.net/TermsofUse#Translations_copyright
     50  i18n:
     51    i18nlib.pm:
     52      extract of
     53        http://svn.openstreetmap.org/applications/editors/josm/i18n/i18n.pl
     54      License: nothing specified, assuming JOSM license: GPL v2 or later
     55    other files:
     56      self written code
     57      License: CC0
  • applications/editors/josm/plugins/photoadjust/i18n/build-i18n.xml

    r30155 r30180  
    77    <property name="gettexttasks.jar" value="../../i18n/lib/gettext-ant-tasks-0.9.7.jar"/>
    88    <property name="plugin.po.dir" location="po"/>
     9    <property name="poimport.tarball" value="latest"/>
    910    <property name="plugin.manifest" location="MANIFEST"/>
    1011
     
    3334        </exec>
    3435    </target>
    35     <target name="poimport" description="Import the PO files from the tarball launchpad-export.tar.gz exported from Launchpad.">
     36    <target name="poimport" description="Import the PO files from Launchpad tarball.">
    3637        <exec executable="perl">
    3738            <arg value="i18n/poimport.pl"/>
    3839            <arg value="--podir"/>
    3940            <arg value="${plugin.po.dir}"/>
     41            <arg value="${poimport.tarball}"/>
    4042        </exec>
    4143    </target>
     
    4547        </exec>
    4648    </target>
    47     <target name="mftrans" description="Add translations of plugin description to manifest.">
     49
     50    <target name="mftrans" description="Add translations of plugin description to manifest.  Not to be called directly.">
    4851        <echo message="Adding translations to ${plugin.manifest} ..."/>
    4952        <exec executable="perl">
  • applications/editors/josm/plugins/photoadjust/i18n/mftrans.pl

    r30155 r30180  
    4747#####################################################################
    4848
    49 ### This file is based on i18n/i18n.pl.  The functions loadfiles(),
    50 ### copystring(), checkpo() and variables used by those functions are
    51 ### a one-to-one copy.
    52 
     49use strict;
    5350use utf8;
    54 #use encoding "utf8";
    55 binmode STDERR, ":encoding(utf8)";
    56 use Term::ReadKey;
    5751use Encode;
    5852use Getopt::Long;
    5953use Pod::Usage;
    60 
    61 my $waswarn = 0;
    62 my $maxcount = 0;
     54use File::Basename;
     55push(@INC, dirname($0));
     56require i18nlib;
    6357
    6458main();
    65 
    66 sub loadfiles($@)
    67 {
    68   my $desc;
    69   my $all;
    70   my ($lang,@files) = @_;
    71   foreach my $file (@files)
    72   {
    73     die "Could not open file $file." if(!open FILE,"<:utf8",$file);
    74     my $linenum = 0;
    75 
    76     my $cnt = -1; # don't count translators info
    77     if($file =~ /\/(.._..(@.+)?)\.po$/ || $file =~ /\/(...?(@.+)?)\.po$/)
    78     {
    79       my $l = $1;
    80       ++$lang->{$l};
    81       my %postate = (last => "", type => "");
    82       my $linenum = 0;
    83       print "Reading file $file\n";
    84       while(<FILE>)
    85       {
    86         ++$linenum;
    87         my $fn = "$file:$linenum";
    88         chomp;
    89         if($_ =~ /^#/ || !$_)
    90         {
    91           checkpo(\%postate, \%all, $l, "line $linenum in $file", $keys, 1);
    92           $postate{fuzzy} = 1 if ($_ =~ /fuzzy/);
    93         }
    94         elsif($_ =~ /^"(.*)"$/) {$postate{last} .= $1;}
    95         elsif($_ =~ /^(msg.+) "(.*)"$/)
    96         {
    97           my ($n, $d) = ($1, $2);
    98           ++$cnt if $n eq "msgid";
    99           my $new = !${postate}{fuzzy} && (($n eq "msgid" && $postate{type} ne "msgctxt") || ($n eq "msgctxt"));
    100           checkpo(\%postate, \%all, $l, "line $linenum in $file", $keys, $new);
    101           $postate{last} = $d;
    102           $postate{type} = $n;
    103           $postate{src} = $fn if $new;
    104         }
    105         else
    106         {
    107           die "Strange line $linenum in $file: $_.";
    108         }
    109       }
    110       checkpo(\%postate, \%all, $l, "line $linenum in $file", $keys, 1);
    111     }
    112     else
    113     {
    114       die "File format not supported for file $file.";
    115     }
    116     $maxcount = $cnt if $cnt > $maxcount;
    117     close(FILE);
    118   }
    119   return %all;
    120 }
    121 
    122 my $alwayspo = 0;
    123 my $alwaysup = 0;
    124 my $noask = 0;
    125 my $conflicts;
    126 sub copystring($$$$$$$)
    127 {
    128   my ($data, $en, $l, $str, $txt, $context, $ispo) = @_;
    129 
    130   $en = "___${context}___$en" if $context;
    131 
    132   if(exists($data->{$en}{$l}) && $data->{$en}{$l} ne $str)
    133   {
    134     return if !$str;
    135     if($l =~ /^_/)
    136     {
    137       $data->{$en}{$l} .= ";$str" if !($data->{$en}{$l} =~ /$str/);
    138     }
    139     elsif(!$data->{$en}{$l})
    140     {
    141       $data->{$en}{$l} = $str;
    142     }
    143     else
    144     {
    145 
    146       my $f = $data->{$en}{_file} || "";
    147       $f = ($f ? "$f;".$data->{$en}{"_src.$l"} : $data->{$en}{"_src.$l"}) if $data->{$en}{"_src.$l"};
    148       my $isotherpo = ($f =~ /\.po\:/);
    149       my $pomode = ($ispo && !$isotherpo) || (!$ispo && $isotherpo);
    150 
    151       my $mis = "String mismatch for '$en' **$str** ($txt) != **$data->{$en}{$l}** ($f)\n";
    152       my $replace = 0;
    153 
    154       if(($conflicts{$l}{$str} || "") eq $data->{$en}{$l}) {}
    155       elsif($pomode && $alwaysup) { $replace=$isotherpo; }
    156       elsif($pomode && $alwayspo) { $replace=$ispo; }
    157       elsif($noask) { print $mis; ++$waswarn; }
    158       else
    159       {
    160         ReadMode 4; # Turn off controls keys
    161         my $arg = "(l)eft, (r)ight";
    162         $arg .= ", (p)o, (u)pstream[ts/mat], all p(o), all up(s)tream" if $pomode;
    163         $arg .= ", e(x)it: ";
    164         print "$mis$arg";
    165         while((my $c = getc()))
    166         {
    167           if($c eq "l") { $replace=1; }
    168           elsif($c eq "r") {}
    169           elsif($c eq "p" && $pomode) { $replace=$ispo; }
    170           elsif($c eq "u" && $pomode) { $replace=$isotherpo; }
    171           elsif($c eq "o" && $pomode) { $alwayspo = 1; $replace=$ispo; }
    172           elsif($c eq "s" && $pomode) { $alwaysup = 1; $replace=$isotherpo; }
    173           elsif($c eq "x") { $noask = 1; ++$waswarn; }
    174           else { print "\n$arg"; next; }
    175           last;
    176         }
    177         print("\n");
    178         ReadMode 0; # Turn on controls keys
    179       }
    180       if(!$noask)
    181       {
    182         if($replace)
    183         {
    184           $data->{$en}{$l} = $str;
    185           $conflicts{$l}{$data->{$en}{$l}} = $str;
    186         }
    187         else
    188         {
    189           $conflicts{$l}{$str} = $data->{$en}{$l};
    190         }
    191       }
    192     }
    193   }
    194   else
    195   {
    196     $data->{$en}{$l} = $str;
    197   }
    198 }
    199 
    200 sub checkpo($$$$$$)
    201 {
    202   my ($postate, $data, $l, $txt, $keys, $new) = @_;
    203 
    204   if($postate->{type} eq "msgid") {$postate->{msgid} = $postate->{last};}
    205   elsif($postate->{type} eq "msgid_plural") {$postate->{msgid_1} = $postate->{last};}
    206   elsif($postate->{type} =~ /^msgstr(\[0\])?$/) {$postate->{msgstr} = $postate->{last};}
    207   elsif($postate->{type} =~ /^msgstr\[(.+)\]$/) {$postate->{"msgstr_$1"} = $postate->{last};}
    208   elsif($postate->{type} eq "msgctxt") {$postate->{context} = $postate->{last};}
    209   elsif($postate->{type}) { die "Strange type $postate->{type} found\n" }
    210 
    211   if($new)
    212   {
    213     if((!$postate->{fuzzy}) && $postate->{msgstr} && $postate->{msgid})
    214     {
    215       copystring($data, $postate->{msgid}, $l, $postate->{msgstr},$txt,$postate->{context}, 1);
    216       for($i = 1; exists($postate->{"msgstr_$i"}); ++$i)
    217       { copystring($data, $postate->{msgid}, "$l.$i", $postate->{"msgstr_$i"},$txt,$postate->{context}, 1); }
    218       if($postate->{msgid_1})
    219       { copystring($data, $postate->{msgid}, "en.1", $postate->{msgid_1},$txt,$postate->{context}, 1); }
    220       copystring($data, $postate->{msgid}, "_src.$l", $postate->{src},$txt,$postate->{context}, 1);
    221     }
    222     elsif($postate->{msgstr} && !$postate->{msgid})
    223     {
    224       my %k = ($postate->{msgstr} =~ /(.+?): +(.+?)\\n/g);
    225       # take the first one!
    226       for $a (sort keys %k)
    227       {
    228         $keys->{$l}{$a} = $k{$a} if !$keys->{$l}{$a};
    229       }
    230     }
    231     foreach my $k (keys %{$postate})
    232     {
    233       delete $postate->{$k};
    234     }
    235     $postate->{type} = $postate->{last} = "";
    236   }
    237 }
    23859
    23960### Add translations of plugin description to manifest.  We write an
     
    296117    }
    297118  }
     119  exit if ($#po < 0);
    298120  my %data = loadfiles(\%lang,@po);
    299121  my $descs = $data{$description};
Note: See TracChangeset for help on using the changeset viewer.