Changeset 30180 in osm for applications/editors/josm
- Timestamp:
- 2014-01-04T17:11:29+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/photoadjust
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/photoadjust/README
r30130 r30180 11 11 to place photos that don't have GPS coordinates associated with them 12 12 on the map, thus to geotag them. 13 14 15 See i18n/README for plugin translation. 13 16 14 17 … … 45 48 licence applicable to JOSM (GPL v2 or any later version), 46 49 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 7 7 <property name="gettexttasks.jar" value="../../i18n/lib/gettext-ant-tasks-0.9.7.jar"/> 8 8 <property name="plugin.po.dir" location="po"/> 9 <property name="poimport.tarball" value="latest"/> 9 10 <property name="plugin.manifest" location="MANIFEST"/> 10 11 … … 33 34 </exec> 34 35 </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."> 36 37 <exec executable="perl"> 37 38 <arg value="i18n/poimport.pl"/> 38 39 <arg value="--podir"/> 39 40 <arg value="${plugin.po.dir}"/> 41 <arg value="${poimport.tarball}"/> 40 42 </exec> 41 43 </target> … … 45 47 </exec> 46 48 </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."> 48 51 <echo message="Adding translations to ${plugin.manifest} ..."/> 49 52 <exec executable="perl"> -
applications/editors/josm/plugins/photoadjust/i18n/mftrans.pl
r30155 r30180 47 47 ##################################################################### 48 48 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 49 use strict; 53 50 use utf8; 54 #use encoding "utf8";55 binmode STDERR, ":encoding(utf8)";56 use Term::ReadKey;57 51 use Encode; 58 52 use Getopt::Long; 59 53 use Pod::Usage; 60 61 my $waswarn = 0;62 my $maxcount = 0;54 use File::Basename; 55 push(@INC, dirname($0)); 56 require i18nlib; 63 57 64 58 main(); 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 info77 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 else106 {107 die "Strange line $linenum in $file: $_.";108 }109 }110 checkpo(\%postate, \%all, $l, "line $linenum in $file", $keys, 1);111 }112 else113 {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 else144 {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 else159 {160 ReadMode 4; # Turn off controls keys161 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 keys179 }180 if(!$noask)181 {182 if($replace)183 {184 $data->{$en}{$l} = $str;185 $conflicts{$l}{$data->{$en}{$l}} = $str;186 }187 else188 {189 $conflicts{$l}{$str} = $data->{$en}{$l};190 }191 }192 }193 }194 else195 {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 }238 59 239 60 ### Add translations of plugin description to manifest. We write an … … 296 117 } 297 118 } 119 exit if ($#po < 0); 298 120 my %data = loadfiles(\%lang,@po); 299 121 my $descs = $data{$description};
Note:
See TracChangeset
for help on using the changeset viewer.