Changeset 31111 in osm for applications/editors/josm
- Timestamp:
- 2015-05-02T15:15:29+02:00 (10 years ago)
- Location:
- applications/editors/josm/i18n
- Files:
-
- 2 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/i18n/build.xml
r31103 r31111 4 4 <property name="josm.build.dir" value="../core"/> 5 5 <property name="josm.presets" value="${josm.build.dir}/data/defaultpresets.xml"/> 6 <!--<property name="josm.style" value="${josm.build.dir}/styles/standard/elemstyles.xml"/>-->7 6 <property name="plugin.dir" value="../plugins"/> 8 <!--<property name="validator.tagfile" value="${josm.build.dir}/data/validator/tagchecker.cfg"/>-->9 7 <property name="maps.srcfile" value="http://josm.openstreetmap.de/maps"/> 8 <property name="wiki.srcfile" value="http://josm.openstreetmap.de/josmfile?mode=en"/> 10 9 <property name="surveyor.srcfile" value="${plugin.dir}/surveyor/resources/surveyor.xml"/> 11 10 <property name="i18n.build.dir" value="build"/> 12 11 <property name="i18n.install.dir" value="${josm.build.dir}/data"/> 12 <property name="i18n_data.install.dir" value="${josm.build.dir}/data_nodist/trans"/> 13 13 <property name="po.build.dir" value="${i18n.build.dir}"/> 14 14 <property name="ant.build.javac.target" value="1.5"/> … … 17 17 <target name="init" description="Loads the Ant gettext and contrib tasks"> 18 18 <taskdef name="gettext-extract" classname="org.xnap.commons.ant.gettext.GettextExtractKeysTask" classpath="${gettexttasks.jar}"/> 19 <taskdef name="gettext-merge" classname="org.xnap.commons.ant.gettext.GettextMergeKeysTask" classpath="${gettexttasks.jar}"/> 20 <taskdef name="gettext-dist" classname="org.xnap.commons.ant.gettext.GettextDistTask" classpath="${gettexttasks.jar}"/> 19 <!-- for the <foreach> possibility --> 21 20 <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${antcontrib.jar}"/> 22 21 </target> … … 28 27 <arg line="convpreset.pl ${josm.presets}"/> 29 28 </exec> 30 <!--<exec executable="perl" output="${i18n.build.dir}/trans_style.java">31 <arg line="convstyle.pl ${josm.style}"/>32 </exec>-->33 <!--<exec executable="perl" failonerror="true" output="${i18n.build.dir}/trans_validator.java">34 <arg line="convvalidator.pl ${validator.tagfile}"/>35 </exec>-->36 29 <exec executable="perl" failonerror="true" output="${i18n.build.dir}/trans_maps.java"> 37 30 <arg line="convmaps.pl ${maps.srcfile}"/> … … 43 36 <arg line="convplugins.pl ${plugin.dir}/*/build.xml"/> 44 37 </exec> 38 <exec executable="perl" failonerror="true"> 39 <arg line="convwiki.pl ${wiki.srcfile} ${i18n.build.dir}/josmfiles ${i18n.build.dir}/josmfiles.zip"/> 40 </exec> 45 41 <copy file="specialmessages.java" todir="${i18n.build.dir}"/> 46 42 </target> … … 50 46 <fileset dir="${i18n.build.dir}" includes="specialmessages.java"/> 51 47 <fileset dir="${i18n.build.dir}" includes="trans_*.java"/> 48 <!-- <fileset dir="${i18n.build.dir}/josmfiles" includes="trans_*.*"/> disable for now --> 52 49 <fileset dir="${josm.build.dir}/data/validator" includes="*.mapcss"/> 53 50 <fileset dir="${josm.build.dir}/styles/standard" includes="*.mapcss"/> … … 55 52 </gettext-extract> 56 53 </target> 57 <target name="po/core.pot" description="Extracts message keys from the JOSM core source code" depends=" builddir,init">54 <target name="po/core.pot" description="Extracts message keys from the JOSM core source code" depends="trans_.java,init"> 58 55 <gettext-extract keysFile="core.pot" poDirectory="po" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3"> 59 56 <fileset dir="${josm.build.dir}/src" includes="**/*.java"/> 60 57 <fileset dir="${i18n.build.dir}" includes="specialmessages.java"/> 61 </gettext-extract> 62 </target> 63 <target name="${i18n.build.dir}/core.2.pot" depends="builddir,po/core.pot" description="Duplicates core.pot for de-duplication in data.pot and plugins.pot"> 64 <copy file="po/core.pot" tofile="${i18n.build.dir}/core.2.pot"/> 65 </target> 66 <target name="po/data.pot" description="Extracts message keys from data files, e.g., presets, imagery (minus core strings)" depends="trans_.java,po/core.pot,${i18n.build.dir}/core.2.pot,init"> 67 <gettext-extract keysFile="data.raw.pot" poDirectory="${i18n.build.dir}" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3"> 68 <fileset dir="${i18n.build.dir}" includes="trans_*.java"/> 58 <fileset dir="${i18n.build.dir}" includes="trans_presets.java"/> 59 <!-- maps should be in data instead, but that requires language file loading support in trac python code --> 60 <fileset dir="${i18n.build.dir}" includes="trans_maps.java"/> 69 61 <fileset dir="${josm.build.dir}/data/validator" includes="*.mapcss"/> 70 62 <fileset dir="${josm.build.dir}/styles/standard" includes="*.mapcss"/> 71 63 </gettext-extract> 64 </target> 65 <target name="po/data.pot" description="Extracts message keys from data files, e.g., presets, imagery (minus core strings)" depends="trans_.java,po/core.pot,init"> 66 <gettext-extract keysFile="data.raw.pot" poDirectory="${i18n.build.dir}" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3"> 67 <fileset dir="${i18n.build.dir}" includes="trans_plugins.java"/> 68 <!-- <fileset dir="${i18n.build.dir}/josmfiles" includes="trans_*.*"/> --> 69 </gettext-extract> 70 <copy todir="${po.build.dir}"> 71 <fileset dir="po" includes="core.pot"/> 72 </copy> 72 73 <exec executable="msgcomm" failonerror="true" output="po/data.pot"> 73 <arg line="--unique po/core.pot ${ i18n.build.dir}/core.2.pot ${i18n.build.dir}/data.raw.pot"/>74 <arg line="--unique po/core.pot ${po.build.dir}/core.pot ${i18n.build.dir}/data.raw.pot"/> 74 75 </exec> 76 <delete file="${po.build.dir}/core.pot"/> 77 <delete file="${po.build.dir}/data.raw.pot"/> 75 78 </target> 76 <target name="po/plugins.pot" description="Extracts message keys from the plugins source code (minus core strings)" depends="po/core.pot,${i18n.build.dir}/core.2.pot,init">79 <target name="po/plugins.pot" description="Extracts message keys from the plugins source code (minus core and data strings)" depends="trans_.java,po/core.pot,po/data.pot,init"> 77 80 <gettext-extract keysFile="plugins.raw.pot" poDirectory="${i18n.build.dir}" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3"> 78 81 <fileset dir="${plugin.dir}" includes="**/*.java"/> 82 <fileset dir="${i18n.build.dir}" includes="trans_surveyor.java"/> 79 83 </gettext-extract> 84 <copy todir="${po.build.dir}"> 85 <fileset dir="po" includes="core.pot"/> 86 <fileset dir="po" includes="data.pot"/> 87 </copy> 80 88 <exec executable="msgcomm" failonerror="true" output="po/plugins.pot"> 81 <arg line="--unique po/core.pot ${ i18n.build.dir}/core.2.pot ${i18n.build.dir}/plugins.raw.pot"/>89 <arg line="--unique po/core.pot ${po.build.dir}/core.pot po/data.pot ${po.build.dir}/data.pot ${i18n.build.dir}/plugins.raw.pot"/> 82 90 </exec> 91 <delete file="${po.build.dir}/core.pot"/> 92 <delete file="${po.build.dir}/data.pot"/> 93 <delete file="${po.build.dir}/plugins.raw.pot"/> 83 94 </target> 84 <target name="build" depends="po/josm.pot,init"> 85 <gettext-merge keysFile="josm.pot" poDirectory="po"/> 95 <target name="build" depends="pot,allpot"> 86 96 <antcall target="coretrans"/> 97 <antcall target="datatrans"/> 87 98 <foreach param="path" target="plugintrans"> 88 99 <path> … … 91 102 </foreach> 92 103 </target> 93 <target name="singleplugintrans" depends=" po/josm.pot,init">104 <target name="singleplugintrans" depends="init"> 94 105 <antcall target="plugintrans"> 95 106 <param name="path" value="${plugin}"/> 96 107 </antcall> 97 108 </target> 98 <target name="buildcore" depends="po/ josm.pot,init">109 <target name="buildcore" depends="po/core.pot,po/data.pot"> 99 110 <antcall target="coretrans"/> 111 <antcall target="datatrans"/> 100 112 </target> 101 113 <target name="coretrans"> 102 <mkdir dir="${po.build.dir}/core"/>103 <gettext-extract keysFile="josm.pot" poDirectory="${po.build.dir}/core" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3">104 <fileset dir="${josm.build.dir}/src" includes="**/*.java"/>105 <fileset dir="${i18n.build.dir}" includes="specialmessages.java"/>106 <fileset dir="${i18n.build.dir}" includes="trans_*.java"/>107 <fileset dir="${josm.build.dir}/data/validator" includes="*.mapcss"/>108 </gettext-extract>109 <copy todir="${po.build.dir}/core">110 <fileset dir="po"/>111 </copy>112 <gettext-merge keysFile="josm.pot" poDirectory="${po.build.dir}/core"/>113 114 <exec executable="perl" failonerror="true"> 114 <arg line="i18n.pl ${i18n.install.dir}/ ${po.build.dir}/core/*.po"/>115 <arg line="i18n.pl --potfile=po/core.pot --basedir=${i18n.install.dir}/ po/*.po"/> 115 116 </exec> 116 117 </target> 117 <target name="plugintrans" depends="init"> 118 <target name="datatrans"> 119 <exec executable="perl" failonerror="true"> 120 <arg line="i18n.pl --potfile=po/data.pot --basedir=${i18n_data.install.dir}/ po/*.po"/> 121 </exec> 122 </target> 123 <target name="plugintrans"> 118 124 <basename file="${path}" property="dir"/> 119 125 <mkdir dir="${po.build.dir}/plugin_${dir}"/> … … 124 130 <fileset dir="${plugin.dir}/${dir}" includes="**/*.java"/> 125 131 <fileset dir="${po.build.dir}/plugin_${dir}" includes="trans_*.java"/> 132 <fileset dir="${i18n.build.dir}" includes="trans_${dir}.java"/> 126 133 </gettext-extract> 127 134 <if> 128 135 <available file="${po.build.dir}/plugin_${dir}/josm.pot"/> 129 136 <then> 130 <copy todir="${po.build.dir}/plugin_${dir}">131 <fileset dir="po"/>132 </copy>133 <gettext-merge keysFile="josm.pot" poDirectory="${po.build.dir}/plugin_${dir}"/>134 137 <exec executable="perl" failonerror="true"> 135 <arg line="i18n.pl ${plugin.dir}/${dir}/data/ ${po.build.dir}/plugin_${dir}/*.po"/>138 <arg line="i18n.pl --potfile=${po.build.dir}/plugin_${dir}/josm.pot --basedir=${plugin.dir}/${dir}/data/ po/*.po"/> 136 139 </exec> 137 140 </then> 138 141 </if> 139 <delete dir="${po.build.dir}/plugin_${dir} "/>142 <delete dir="${po.build.dir}/plugin_${dir}ss"/> 140 143 </target> 141 144 <target name="clean"> … … 149 152 </delete> 150 153 </target> 151 <target name="test" >154 <target name="test" depends="pot"> 152 155 <mkdir dir="${i18n.build.dir}/test"/> 153 156 <exec executable="perl" failonerror="true"> 154 <arg line="i18n.pl ${i18n.build.dir}/test/ po/*.po"/>157 <arg line="i18n.pl --potfile=po/josm.pot --basedir=${i18n.build.dir}/test/ po/*.po"/> 155 158 </exec> 156 159 </target> 157 160 <target name="pot" depends="po/josm.pot" /> 158 <target name=" transifex" depends="po/core.pot,po/plugins.pot,po/data.pot" />161 <target name="allpot" depends="po/core.pot,po/data.pot,po/plugins.pot" /> 159 162 <target name="update"> 160 163 <exec executable="perl" failonerror="true"> -
applications/editors/josm/i18n/convmaps.pl
r31030 r31111 6 6 use strict; 7 7 use LWP::Simple; 8 use encoding 'utf8';8 use open qw/:std :encoding(utf8)/; 9 9 10 10 my $item; -
applications/editors/josm/i18n/convpreset.pl
r31076 r31111 140 140 # display_values / values 141 141 my $sp = ($line =~ /delimiter="(.*?)"/) ? $1 : ($type eq "combo" ? ",":";"); 142 my $vals = ($line =~ / display_values="(.*?)"/) ? $1 : ($line =~ /values="(.*?)"/) ? $1 : undef;142 my $vals = ($line =~ / display_values="(.*?)"/) ? $1 : ($line =~ /values="(.*?)"/) ? $1 : undef; 143 143 if($vals) 144 144 { … … 184 184 print "\n"; 185 185 } 186 elsif($line =~ /<\/ combo/)186 elsif($line =~ /<\/(combo|multiselect)/) 187 187 { 188 188 $combo_n = ""; … … 212 212 || $comment) 213 213 { 214 print "// $line\n"; 214 $line =~ s/[ \t]+((?:short)?description) *= *"([^"]+)/*\/ \/* $1 *\/ tr("$2"); \/*/g; 215 print "/* $line */\n"; 215 216 } 216 217 else -
applications/editors/josm/i18n/convstyle.pl
r29999 r31111 65 65 else 66 66 { 67 $line =~ s/[ \t]+((?:short)?description) *= *"([^"]+)/*\/ \/* $1 *\/ tr("$2"); \/*/g; 67 68 print "/* $line */\n"; 68 69 } -
applications/editors/josm/i18n/i18n.pl
r31088 r31111 2 2 3 3 use utf8; 4 use strict; 4 5 use open qw/:std :encoding(utf8)/; 5 6 use Term::ReadKey; … … 7 8 8 9 my $waswarn = 0; 9 my $maxcount = 0;10 10 my $lang_pattern = '([a-z]{2}_[A-Z]{2}|[a-z]{2,3}|[a-z]{2}\@[a-z]+)'; 11 11 my $lang_pattern_file = '([a-z]{2}_[A-Z]{2}|[a-z]{2,3}|[a-z]{2}-[a-z]+)'; … … 20 20 } 21 21 22 sub loadfiles($@) 22 sub loadpot($) 23 { 24 my ($file) = @_; 25 my %all = (); 26 my %keys = (); 27 die "Could not open file $file." if(!open FILE,"<:utf8",$file); 28 my %postate = (last => "", type => ""); 29 my $linenum = 0; 30 print "Reading file $file\n"; 31 while(<FILE>) 32 { 33 ++$linenum; 34 my $fn = "$file:$linenum"; 35 chomp; 36 if($_ =~ /^#/ || !$_) 37 { 38 checkpo(\%postate, \%all, "pot", "line $linenum in $file", \%keys, 1, undef); 39 $postate{fuzzy} = 1 if ($_ =~ /fuzzy/); 40 } 41 elsif($_ =~ /^"(.*)"$/) {$postate{last} .= $1;} 42 elsif($_ =~ /^(msg.+) "(.*)"$/) 43 { 44 my ($n, $d) = ($1, $2); 45 my $new = !${postate}{fuzzy} && (($n eq "msgid" && $postate{type} ne "msgctxt") || ($n eq "msgctxt")); 46 checkpo(\%postate, \%all, "pot", "line $linenum in $file", \%keys, $new, undef); 47 $postate{last} = $d; 48 $postate{type} = $n; 49 $postate{src} = $fn if $new; 50 } 51 else 52 { 53 die "Strange line $linenum in $file: $_."; 54 } 55 } 56 checkpo(\%postate, \%all, "pot", "line $linenum in $file", \%keys, 1, undef); 57 close(FILE); 58 return \%all; 59 } 60 61 sub loadfiles($$@) 23 62 { 24 63 my $desc; 25 my $all; 26 my ($lang,@files) = @_; 64 my %all = (); 65 my %keys = (); 66 my ($lang,$use,@files) = @_; 27 67 foreach my $file (@files) 28 68 { 29 69 die "Could not open file $file." if(!open FILE,"<:utf8",$file); 30 my $linenum = 0; 31 32 my $cnt = -1; # don't count translators info 70 33 71 if($file =~ /\/$lang_pattern\.po$/) 34 72 { … … 45 83 if($_ =~ /^#/ || !$_) 46 84 { 47 checkpo(\%postate, \%all, $l, "line $linenum in $file", $keys, 1);85 checkpo(\%postate, \%all, $l, "line $linenum in $file", \%keys, 1, $use); 48 86 $postate{fuzzy} = 1 if ($_ =~ /fuzzy/); 49 87 } … … 52 90 { 53 91 my ($n, $d) = ($1, $2); 54 ++$cnt if $n eq "msgid";55 92 my $new = !${postate}{fuzzy} && (($n eq "msgid" && $postate{type} ne "msgctxt") || ($n eq "msgctxt")); 56 checkpo(\%postate, \%all, $l, "line $linenum in $file", $keys, $new);93 checkpo(\%postate, \%all, $l, "line $linenum in $file", \%keys, $new, $use); 57 94 $postate{last} = $d; 58 95 $postate{type} = $n; … … 64 101 } 65 102 } 66 checkpo(\%postate, \%all, $l, "line $linenum in $file", $keys, 1);103 checkpo(\%postate, \%all, $l, "line $linenum in $file", \%keys, 1, $use); 67 104 } 68 105 else … … 70 107 die "File format not supported for file $file."; 71 108 } 72 $maxcount = $cnt if $cnt > $maxcount;73 109 close(FILE); 74 110 } … … 79 115 my $alwaysup = 0; 80 116 my $noask = 0; 81 my $conflicts;117 my %conflicts; 82 118 sub copystring($$$$$$$) 83 119 { … … 99 135 else 100 136 { 101 102 137 my $f = $data->{$en}{_file} || ""; 103 138 $f = ($f ? "$f;".$data->{$en}{"_src.$l"} : $data->{$en}{"_src.$l"}) if $data->{$en}{"_src.$l"}; … … 154 189 } 155 190 156 sub checkpo($$$$$$) 157 { 158 my ($postate, $data, $l, $txt, $keys, $new) = @_; 191 # Check a current state for new data 192 # 193 # @param postate Pointer to current status hash 194 # @param data Pointer to final data array 195 # @param l current language 196 # @param txt output text in case of error, usually file and line number 197 # @param keys pointer to hash for info keys extracted from the first msgid "" entry 198 # @param new whether a data set is finish or not yet complete 199 # @param use hash to strings to use or undef for all strings 200 # 201 sub checkpo($$$$$$$) 202 { 203 my ($postate, $data, $l, $txt, $keys, $new, $use) = @_; 159 204 160 205 if($postate->{type} eq "msgid") {$postate->{msgid} = $postate->{last};} … … 167 212 if($new) 168 213 { 169 if((!$postate->{fuzzy}) && $postate->{msgstr} && $postate->{msgid}) 214 my $en = $postate->{context} ? "___$postate->{context}___$postate->{msgid}" : $postate->{msgid}; 215 if((!$postate->{fuzzy}) && ($l eq "pot" || $postate->{msgstr}) && $postate->{msgid} 216 && (!$use || $use->{$en})) 170 217 { 171 218 copystring($data, $postate->{msgid}, $l, $postate->{msgstr},$txt,$postate->{context}, 1); 172 for($i = 1; exists($postate->{"msgstr_$i"}); ++$i) 173 { copystring($data, $postate->{msgid}, "$l.$i", $postate->{"msgstr_$i"},$txt,$postate->{context}, 1); } 174 if($postate->{msgid_1}) 175 { copystring($data, $postate->{msgid}, "en.1", $postate->{msgid_1},$txt,$postate->{context}, 1); } 219 if(!$use || $use->{$en}{"en.1"}) 220 { 221 for(my $i = 1; exists($postate->{"msgstr_$i"}); ++$i) 222 { copystring($data, $postate->{msgid}, "$l.$i", $postate->{"msgstr_$i"},$txt,$postate->{context}, 1); } 223 if($postate->{msgid_1}) 224 { copystring($data, $postate->{msgid}, "en.1", $postate->{msgid_1},$txt,$postate->{context}, 1); } 225 } 176 226 copystring($data, $postate->{msgid}, "_src.$l", $postate->{src},$txt,$postate->{context}, 1); 177 227 } … … 259 309 $maxlen = $len if $len > $maxlen; 260 310 } 311 my $maxcount = keys(%{$data}); 261 312 foreach my $file (@files) 262 313 { … … 306 357 { } 307 358 my $val; 308 $eq = 0;359 my $eq = 0; 309 360 if($la eq "en") 310 361 { … … 357 408 my %lang; 358 409 my @po; 359 my $basename = shift @ARGV; 410 my $potfile; 411 my $basename = "./"; 412 foreach my $arg (@ARGV) 413 { 414 next if $arg !~ /^--/; 415 if($arg =~ /^--basedir=(.+)$/) 416 { 417 $basename = $1; 418 } 419 elsif($arg =~ /^--potfile=(.+)$/) 420 { 421 $potfile = $1; 422 } 423 else 424 { 425 die "Unknown argument $arg."; 426 } 427 } 360 428 $basename .= "/" if !($basename =~ /[\/\\:]$/); 361 429 foreach my $arg (@ARGV) 362 430 { 431 next if $arg =~ /^--/; 363 432 foreach my $f (glob $arg) 364 433 { … … 368 437 } 369 438 } 370 my %data = loadfiles(\%lang,@po); 439 my %data = loadfiles(\%lang,$potfile ? loadpot($potfile) : undef, @po); 440 371 441 my @clang; 372 442 foreach my $la (sort keys %lang)
Note:
See TracChangeset
for help on using the changeset viewer.