Index: /applications/editors/josm/i18n/build.xml
===================================================================
--- /applications/editors/josm/i18n/build.xml	(revision 31110)
+++ /applications/editors/josm/i18n/build.xml	(revision 31111)
@@ -4,11 +4,11 @@
     <property name="josm.build.dir" value="../core"/>
     <property name="josm.presets" value="${josm.build.dir}/data/defaultpresets.xml"/>
-    <!--<property name="josm.style" value="${josm.build.dir}/styles/standard/elemstyles.xml"/>-->
     <property name="plugin.dir" value="../plugins"/>
-    <!--<property name="validator.tagfile" value="${josm.build.dir}/data/validator/tagchecker.cfg"/>-->
     <property name="maps.srcfile" value="http://josm.openstreetmap.de/maps"/>
+    <property name="wiki.srcfile" value="http://josm.openstreetmap.de/josmfile?mode=en"/>
     <property name="surveyor.srcfile" value="${plugin.dir}/surveyor/resources/surveyor.xml"/>
     <property name="i18n.build.dir" value="build"/>
     <property name="i18n.install.dir" value="${josm.build.dir}/data"/>
+    <property name="i18n_data.install.dir" value="${josm.build.dir}/data_nodist/trans"/>
     <property name="po.build.dir" value="${i18n.build.dir}"/>
     <property name="ant.build.javac.target" value="1.5"/>
@@ -17,6 +17,5 @@
     <target name="init" description="Loads the Ant gettext and contrib tasks">
         <taskdef name="gettext-extract" classname="org.xnap.commons.ant.gettext.GettextExtractKeysTask" classpath="${gettexttasks.jar}"/>
-        <taskdef name="gettext-merge" classname="org.xnap.commons.ant.gettext.GettextMergeKeysTask" classpath="${gettexttasks.jar}"/>
-        <taskdef name="gettext-dist" classname="org.xnap.commons.ant.gettext.GettextDistTask" classpath="${gettexttasks.jar}"/>
+        <!-- for the <foreach> possibility -->
         <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${antcontrib.jar}"/>
     </target>
@@ -28,10 +27,4 @@
             <arg line="convpreset.pl ${josm.presets}"/>
         </exec>
-        <!--<exec executable="perl" output="${i18n.build.dir}/trans_style.java">
-            <arg line="convstyle.pl ${josm.style}"/>
-        </exec>-->
-        <!--<exec executable="perl" failonerror="true" output="${i18n.build.dir}/trans_validator.java">
-            <arg line="convvalidator.pl ${validator.tagfile}"/>
-        </exec>-->
         <exec executable="perl" failonerror="true" output="${i18n.build.dir}/trans_maps.java">
             <arg line="convmaps.pl ${maps.srcfile}"/>
@@ -43,4 +36,7 @@
             <arg line="convplugins.pl ${plugin.dir}/*/build.xml"/>
         </exec>
+        <exec executable="perl" failonerror="true">
+            <arg line="convwiki.pl ${wiki.srcfile} ${i18n.build.dir}/josmfiles ${i18n.build.dir}/josmfiles.zip"/>
+        </exec>
         <copy file="specialmessages.java" todir="${i18n.build.dir}"/>
     </target>
@@ -50,4 +46,5 @@
             <fileset dir="${i18n.build.dir}" includes="specialmessages.java"/>
             <fileset dir="${i18n.build.dir}" includes="trans_*.java"/>
+            <!-- <fileset dir="${i18n.build.dir}/josmfiles" includes="trans_*.*"/> disable for now -->
             <fileset dir="${josm.build.dir}/data/validator" includes="*.mapcss"/>
             <fileset dir="${josm.build.dir}/styles/standard" includes="*.mapcss"/>
@@ -55,34 +52,48 @@
         </gettext-extract>
     </target>
-    <target name="po/core.pot" description="Extracts message keys from the JOSM core source code" depends="builddir,init">
+    <target name="po/core.pot" description="Extracts message keys from the JOSM core source code" depends="trans_.java,init">
         <gettext-extract keysFile="core.pot" poDirectory="po" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3">
             <fileset dir="${josm.build.dir}/src" includes="**/*.java"/>
             <fileset dir="${i18n.build.dir}" includes="specialmessages.java"/>
-        </gettext-extract>
-    </target>
-    <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">
-        <copy file="po/core.pot" tofile="${i18n.build.dir}/core.2.pot"/>
-    </target>
-    <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">
-        <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">
-            <fileset dir="${i18n.build.dir}" includes="trans_*.java"/>
+            <fileset dir="${i18n.build.dir}" includes="trans_presets.java"/>
+            <!-- maps should be in data instead, but that requires language file loading support in trac python code -->
+            <fileset dir="${i18n.build.dir}" includes="trans_maps.java"/>
             <fileset dir="${josm.build.dir}/data/validator" includes="*.mapcss"/>
             <fileset dir="${josm.build.dir}/styles/standard" includes="*.mapcss"/>
         </gettext-extract>
+    </target>
+    <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">
+        <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">
+            <fileset dir="${i18n.build.dir}" includes="trans_plugins.java"/>
+            <!-- <fileset dir="${i18n.build.dir}/josmfiles" includes="trans_*.*"/> -->
+        </gettext-extract>
+        <copy todir="${po.build.dir}">
+            <fileset dir="po" includes="core.pot"/>
+        </copy>
         <exec executable="msgcomm" failonerror="true" output="po/data.pot">
-            <arg line="--unique po/core.pot ${i18n.build.dir}/core.2.pot ${i18n.build.dir}/data.raw.pot"/>
+            <arg line="--unique po/core.pot ${po.build.dir}/core.pot ${i18n.build.dir}/data.raw.pot"/>
         </exec>
+        <delete file="${po.build.dir}/core.pot"/>
+        <delete file="${po.build.dir}/data.raw.pot"/>
     </target>
-    <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">
+    <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">
         <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">
             <fileset dir="${plugin.dir}" includes="**/*.java"/>
+            <fileset dir="${i18n.build.dir}" includes="trans_surveyor.java"/>
         </gettext-extract>
+        <copy todir="${po.build.dir}">
+            <fileset dir="po" includes="core.pot"/>
+            <fileset dir="po" includes="data.pot"/>
+        </copy>
         <exec executable="msgcomm" failonerror="true" output="po/plugins.pot">
-            <arg line="--unique po/core.pot ${i18n.build.dir}/core.2.pot ${i18n.build.dir}/plugins.raw.pot"/>
+            <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"/>
         </exec>
+        <delete file="${po.build.dir}/core.pot"/>
+        <delete file="${po.build.dir}/data.pot"/>
+        <delete file="${po.build.dir}/plugins.raw.pot"/>
     </target>
-    <target name="build" depends="po/josm.pot,init">
-        <gettext-merge keysFile="josm.pot" poDirectory="po"/>
+    <target name="build" depends="pot,allpot">
         <antcall target="coretrans"/>
+        <antcall target="datatrans"/>
         <foreach param="path" target="plugintrans">
             <path>
@@ -91,29 +102,24 @@
         </foreach>
     </target>
-    <target name="singleplugintrans" depends="po/josm.pot,init">
+    <target name="singleplugintrans" depends="init">
         <antcall target="plugintrans">
             <param name="path" value="${plugin}"/>
         </antcall>
     </target>
-    <target name="buildcore" depends="po/josm.pot,init">
+    <target name="buildcore" depends="po/core.pot,po/data.pot">
         <antcall target="coretrans"/>
+        <antcall target="datatrans"/>
     </target>
     <target name="coretrans">
-        <mkdir dir="${po.build.dir}/core"/>
-        <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">
-            <fileset dir="${josm.build.dir}/src" includes="**/*.java"/>
-            <fileset dir="${i18n.build.dir}" includes="specialmessages.java"/>
-            <fileset dir="${i18n.build.dir}" includes="trans_*.java"/>
-            <fileset dir="${josm.build.dir}/data/validator" includes="*.mapcss"/>
-        </gettext-extract>
-        <copy todir="${po.build.dir}/core">
-            <fileset dir="po"/>
-        </copy>
-        <gettext-merge keysFile="josm.pot" poDirectory="${po.build.dir}/core"/>
         <exec executable="perl" failonerror="true">
-            <arg line="i18n.pl ${i18n.install.dir}/ ${po.build.dir}/core/*.po"/>
+            <arg line="i18n.pl --potfile=po/core.pot --basedir=${i18n.install.dir}/ po/*.po"/>
         </exec>
     </target>
-    <target name="plugintrans" depends="init">
+    <target name="datatrans">
+        <exec executable="perl" failonerror="true">
+            <arg line="i18n.pl --potfile=po/data.pot --basedir=${i18n_data.install.dir}/ po/*.po"/>
+        </exec>
+    </target>
+    <target name="plugintrans">
         <basename file="${path}" property="dir"/>
         <mkdir dir="${po.build.dir}/plugin_${dir}"/>
@@ -124,18 +130,15 @@
             <fileset dir="${plugin.dir}/${dir}" includes="**/*.java"/>
             <fileset dir="${po.build.dir}/plugin_${dir}" includes="trans_*.java"/>
+            <fileset dir="${i18n.build.dir}" includes="trans_${dir}.java"/>
         </gettext-extract>
         <if>
             <available file="${po.build.dir}/plugin_${dir}/josm.pot"/>
             <then>
-                <copy todir="${po.build.dir}/plugin_${dir}">
-                    <fileset dir="po"/>
-                </copy>
-                <gettext-merge keysFile="josm.pot" poDirectory="${po.build.dir}/plugin_${dir}"/>
                 <exec executable="perl" failonerror="true">
-                    <arg line="i18n.pl ${plugin.dir}/${dir}/data/ ${po.build.dir}/plugin_${dir}/*.po"/>
+                    <arg line="i18n.pl --potfile=${po.build.dir}/plugin_${dir}/josm.pot --basedir=${plugin.dir}/${dir}/data/ po/*.po"/>
                 </exec>
             </then>
         </if>
-        <delete dir="${po.build.dir}/plugin_${dir}"/>
+        <delete dir="${po.build.dir}/plugin_${dir}ss"/>
     </target>
     <target name="clean">
@@ -149,12 +152,12 @@
         </delete>
     </target>
-    <target name="test">
+    <target name="test" depends="pot">
         <mkdir dir="${i18n.build.dir}/test"/>
         <exec executable="perl" failonerror="true">
-            <arg line="i18n.pl ${i18n.build.dir}/test/ po/*.po"/>
+            <arg line="i18n.pl --potfile=po/josm.pot --basedir=${i18n.build.dir}/test/ po/*.po"/>
         </exec>
     </target>
     <target name="pot" depends="po/josm.pot" />
-    <target name="transifex" depends="po/core.pot,po/plugins.pot,po/data.pot" />
+    <target name="allpot" depends="po/core.pot,po/data.pot,po/plugins.pot" />
     <target name="update">
         <exec executable="perl" failonerror="true">
Index: /applications/editors/josm/i18n/convcss.pl
===================================================================
--- /applications/editors/josm/i18n/convcss.pl	(revision 31111)
+++ /applications/editors/josm/i18n/convcss.pl	(revision 31111)
@@ -0,0 +1,14 @@
+#! /usr/bin/perl -w
+
+# Written by Dirk Stöcker <openstreetmap@dstoecker.de>
+# Public domain, no rights reserved.
+
+use strict;
+
+my $skipmore = 0;
+while(my $line = <>)
+{
+  $skipmore = 1 if $line =~ /meta\[lang/;
+  $line =~ s/((?:title|description): +)(.*)(;)/$1tr($2)$3/ if !$skipmore;
+  print $line;
+}
Index: /applications/editors/josm/i18n/convmaps.pl
===================================================================
--- /applications/editors/josm/i18n/convmaps.pl	(revision 31110)
+++ /applications/editors/josm/i18n/convmaps.pl	(revision 31111)
@@ -6,5 +6,5 @@
 use strict;
 use LWP::Simple;
-use encoding 'utf8';
+use open qw/:std :encoding(utf8)/;
 
 my $item;
Index: /applications/editors/josm/i18n/convpreset.pl
===================================================================
--- /applications/editors/josm/i18n/convpreset.pl	(revision 31110)
+++ /applications/editors/josm/i18n/convpreset.pl	(revision 31111)
@@ -140,5 +140,5 @@
     # display_values / values
     my $sp = ($line =~ /delimiter="(.*?)"/) ? $1 : ($type eq "combo" ? ",":";");
-    my $vals = ($line =~ /display_values="(.*?)"/) ? $1 : ($line =~ /values="(.*?)"/) ? $1 : undef;
+    my $vals = ($line =~ / display_values="(.*?)"/) ? $1 : ($line =~ /values="(.*?)"/) ? $1 : undef;
     if($vals)
     {
@@ -184,5 +184,5 @@
     print "\n";
   }
-  elsif($line =~ /<\/combo/)
+  elsif($line =~ /<\/(combo|multiselect)/)
   {
     $combo_n = "";
@@ -212,5 +212,6 @@
      || $comment)
   {
-    print "// $line\n";
+    $line =~ s/[ \t]+((?:short)?description) *= *"([^"]+)/*\/ \/* $1 *\/ tr("$2"); \/*/g;
+    print "/* $line */\n";
   }
   else
Index: /applications/editors/josm/i18n/convstyle.pl
===================================================================
--- /applications/editors/josm/i18n/convstyle.pl	(revision 31110)
+++ /applications/editors/josm/i18n/convstyle.pl	(revision 31111)
@@ -65,4 +65,5 @@
   else
   {
+    $line =~ s/[ \t]+((?:short)?description) *= *"([^"]+)/*\/ \/* $1 *\/ tr("$2"); \/*/g;
     print "/* $line */\n";
   }
Index: plications/editors/josm/i18n/convvalidator.pl
===================================================================
--- /applications/editors/josm/i18n/convvalidator.pl	(revision 31110)
+++ 	(revision )
@@ -1,40 +1,0 @@
-#! /usr/bin/perl -w
-
-# Written by Dirk Stöcker <openstreetmap@dstoecker.de>
-# Public domain, no rights reserved.
-
-use strict;
-
-my $item;
-my $comment = 0;
-
-# This is a simple conversion and in no way a complete XML parser
-# but it works with a default Perl installation
-
-# Print a header to write valid Java code.  No line break,
-# so that the input and output line numbers will match.
-print "class trans_validator { void tr(String s){} void f() {";
-
-while(my $line = <>)
-{
-  chomp($line);
-  print "tr(\"\"); ";
-  if($line =~ /^#(.*)$/)
-  {
-    print "/* $1 */\n";
-  }
-  elsif($line =~ /^$/)
-  {
-    print "\n";
-  }
-  elsif($line =~ /(.*) *# *(.*) *$/)
-  {
-    print "/* $1 */ tr(\"$2\");\n";
-  }
-  else
-  {
-    print "/* $line */\n";
-  }
-}
-
-print "}}\n";
Index: /applications/editors/josm/i18n/convwiki.pl
===================================================================
--- /applications/editors/josm/i18n/convwiki.pl	(revision 31111)
+++ /applications/editors/josm/i18n/convwiki.pl	(revision 31111)
@@ -0,0 +1,53 @@
+#! /usr/bin/perl -w
+
+# Written by Dirk Stöcker <openstreetmap@dstoecker.de>
+# Public domain, no rights reserved.
+
+use strict;
+use LWP::Simple;
+use open qw/:std :encoding(utf8)/;
+
+my $filename;
+my $dir = $ARGV[1] || "build/josmfiles";
+if($ARGV[0] && $ARGV[0] =~ /^http:\/\//)
+{
+  $filename = $ARGV[2] || "build/josmfiles.zip";
+  my $content = get($ARGV[0]);
+  die "Couldn't get $ARGV[0]" unless defined $content;
+  open FILE,">:raw",$filename or die "Could not open $filename";
+  print FILE $content;
+  close FILE
+}
+else
+{
+  $filename = $ARGV[0];
+}
+system "rm -rf $dir/";
+print "Extracting to $dir\n";
+mkdir $dir;
+system "unzip -q -d $dir $filename";
+foreach my $name (glob "$dir/*")
+{
+  if($name =~ /^(.*?)([^\/]+-preset\.xml)$/)
+  {
+    system "mv $name $name.orig";
+    my ($path, $xmlname) = ($1, $2);
+    my $res = `xmllint --format --schema ../core/data/tagging-preset.xsd $name.orig --encode utf-8 --output $name 2>&1`;
+    print $res if $res !~ /\.orig validates/;
+    system "perl convpreset.pl $name >${path}trans_$xmlname";
+    unlink "$name.orig";
+  }
+  elsif($name =~ /^(.*?)([^\/]+-style\.xml$)/)
+  {
+    system "perl convstyle.pl $name >${1}trans_$2";
+  }
+  elsif($name =~ /^(.*?)([^\/]+\.mapcss)$/)
+  {
+    system "perl convcss.pl $name >${1}trans_$2";
+  }
+  else
+  {
+    die "Unknown file type $name.";
+  }
+  unlink $name;
+}
Index: /applications/editors/josm/i18n/i18n.pl
===================================================================
--- /applications/editors/josm/i18n/i18n.pl	(revision 31110)
+++ /applications/editors/josm/i18n/i18n.pl	(revision 31111)
@@ -2,4 +2,5 @@
 
 use utf8;
+use strict;
 use open qw/:std :encoding(utf8)/;
 use Term::ReadKey;
@@ -7,5 +8,4 @@
 
 my $waswarn = 0;
-my $maxcount = 0;
 my $lang_pattern = '([a-z]{2}_[A-Z]{2}|[a-z]{2,3}|[a-z]{2}\@[a-z]+)';
 my $lang_pattern_file = '([a-z]{2}_[A-Z]{2}|[a-z]{2,3}|[a-z]{2}-[a-z]+)';
@@ -20,15 +20,53 @@
 }
 
-sub loadfiles($@)
+sub loadpot($)
+{
+  my ($file) = @_;
+  my %all = ();
+  my %keys = ();
+  die "Could not open file $file." if(!open FILE,"<:utf8",$file);
+  my %postate = (last => "", type => "");
+  my $linenum = 0;
+  print "Reading file $file\n";
+  while(<FILE>)
+  {
+    ++$linenum;
+    my $fn = "$file:$linenum";
+    chomp;
+    if($_ =~ /^#/ || !$_)
+    {
+      checkpo(\%postate, \%all, "pot", "line $linenum in $file", \%keys, 1, undef);
+      $postate{fuzzy} = 1 if ($_ =~ /fuzzy/);
+    }
+    elsif($_ =~ /^"(.*)"$/) {$postate{last} .= $1;}
+    elsif($_ =~ /^(msg.+) "(.*)"$/)
+    {
+      my ($n, $d) = ($1, $2);
+      my $new = !${postate}{fuzzy} && (($n eq "msgid" && $postate{type} ne "msgctxt") || ($n eq "msgctxt"));
+      checkpo(\%postate, \%all, "pot", "line $linenum in $file", \%keys, $new, undef);
+      $postate{last} = $d;
+      $postate{type} = $n;
+      $postate{src} = $fn if $new;
+    }
+    else
+    {
+      die "Strange line $linenum in $file: $_.";
+    }
+  }
+  checkpo(\%postate, \%all, "pot", "line $linenum in $file", \%keys, 1, undef);
+  close(FILE);
+  return \%all;
+}
+
+sub loadfiles($$@)
 {
   my $desc;
-  my $all;
-  my ($lang,@files) = @_;
+  my %all = ();
+  my %keys = ();
+  my ($lang,$use,@files) = @_;
   foreach my $file (@files)
   {
     die "Could not open file $file." if(!open FILE,"<:utf8",$file);
-    my $linenum = 0;
-
-    my $cnt = -1; # don't count translators info
+
     if($file =~ /\/$lang_pattern\.po$/)
     {
@@ -45,5 +83,5 @@
         if($_ =~ /^#/ || !$_)
         {
-          checkpo(\%postate, \%all, $l, "line $linenum in $file", $keys, 1);
+          checkpo(\%postate, \%all, $l, "line $linenum in $file", \%keys, 1, $use);
           $postate{fuzzy} = 1 if ($_ =~ /fuzzy/);
         }
@@ -52,7 +90,6 @@
         {
           my ($n, $d) = ($1, $2);
-          ++$cnt if $n eq "msgid";
           my $new = !${postate}{fuzzy} && (($n eq "msgid" && $postate{type} ne "msgctxt") || ($n eq "msgctxt"));
-          checkpo(\%postate, \%all, $l, "line $linenum in $file", $keys, $new);
+          checkpo(\%postate, \%all, $l, "line $linenum in $file", \%keys, $new, $use);
           $postate{last} = $d;
           $postate{type} = $n;
@@ -64,5 +101,5 @@
         }
       }
-      checkpo(\%postate, \%all, $l, "line $linenum in $file", $keys, 1);
+      checkpo(\%postate, \%all, $l, "line $linenum in $file", \%keys, 1, $use);
     }
     else
@@ -70,5 +107,4 @@
       die "File format not supported for file $file.";
     }
-    $maxcount = $cnt if $cnt > $maxcount;
     close(FILE);
   }
@@ -79,5 +115,5 @@
 my $alwaysup = 0;
 my $noask = 0;
-my $conflicts;
+my %conflicts;
 sub copystring($$$$$$$)
 {
@@ -99,5 +135,4 @@
     else
     {
-
       my $f = $data->{$en}{_file} || "";
       $f = ($f ? "$f;".$data->{$en}{"_src.$l"} : $data->{$en}{"_src.$l"}) if $data->{$en}{"_src.$l"};
@@ -154,7 +189,17 @@
 }
 
-sub checkpo($$$$$$)
-{
-  my ($postate, $data, $l, $txt, $keys, $new) = @_;
+# Check a current state for new data
+#
+# @param postate Pointer to current status hash
+# @param data    Pointer to final data array
+# @param l       current language
+# @param txt     output text in case of error, usually file and line number
+# @param keys    pointer to hash for info keys extracted from the first msgid "" entry
+# @param new     whether a data set is finish or not yet complete
+# @param use     hash to strings to use or undef for all strings
+#
+sub checkpo($$$$$$$)
+{
+  my ($postate, $data, $l, $txt, $keys, $new, $use) = @_;
 
   if($postate->{type} eq "msgid") {$postate->{msgid} = $postate->{last};}
@@ -167,11 +212,16 @@
   if($new)
   {
-    if((!$postate->{fuzzy}) && $postate->{msgstr} && $postate->{msgid})
+    my $en = $postate->{context} ?  "___$postate->{context}___$postate->{msgid}" : $postate->{msgid};
+    if((!$postate->{fuzzy}) && ($l eq "pot" || $postate->{msgstr}) && $postate->{msgid}
+    && (!$use || $use->{$en}))
     {
       copystring($data, $postate->{msgid}, $l, $postate->{msgstr},$txt,$postate->{context}, 1);
-      for($i = 1; exists($postate->{"msgstr_$i"}); ++$i)
-      { copystring($data, $postate->{msgid}, "$l.$i", $postate->{"msgstr_$i"},$txt,$postate->{context}, 1); }
-      if($postate->{msgid_1})
-      { copystring($data, $postate->{msgid}, "en.1", $postate->{msgid_1},$txt,$postate->{context}, 1); }
+      if(!$use || $use->{$en}{"en.1"})
+      {
+        for(my $i = 1; exists($postate->{"msgstr_$i"}); ++$i)
+        { copystring($data, $postate->{msgid}, "$l.$i", $postate->{"msgstr_$i"},$txt,$postate->{context}, 1); }
+        if($postate->{msgid_1})
+        { copystring($data, $postate->{msgid}, "en.1", $postate->{msgid_1},$txt,$postate->{context}, 1); }
+      }
       copystring($data, $postate->{msgid}, "_src.$l", $postate->{src},$txt,$postate->{context}, 1);
     }
@@ -259,4 +309,5 @@
     $maxlen = $len if $len > $maxlen;
   }
+  my $maxcount = keys(%{$data});
   foreach my $file (@files)
   {
@@ -306,5 +357,5 @@
       { }
       my $val;
-      $eq = 0;
+      my $eq = 0;
       if($la eq "en")
       {
@@ -357,8 +408,26 @@
   my %lang;
   my @po;
-  my $basename = shift @ARGV;
+  my $potfile;
+  my $basename = "./";
+  foreach my $arg (@ARGV)
+  {
+    next if $arg !~ /^--/;
+    if($arg =~ /^--basedir=(.+)$/)
+    {
+      $basename = $1;
+    }
+    elsif($arg =~ /^--potfile=(.+)$/)
+    {
+      $potfile = $1;
+    }
+    else
+    {
+      die "Unknown argument $arg.";
+    }
+  }
   $basename .= "/" if !($basename =~ /[\/\\:]$/);
   foreach my $arg (@ARGV)
   {
+    next if $arg =~ /^--/;
     foreach my $f (glob $arg)
     {
@@ -368,5 +437,6 @@
     }
   }
-  my %data = loadfiles(\%lang,@po);
+  my %data = loadfiles(\%lang,$potfile ? loadpot($potfile) : undef, @po);
+
   my @clang;
   foreach my $la (sort keys %lang)
