Index: /applications/editors/josm/plugins/photoadjust/build.xml
===================================================================
--- /applications/editors/josm/plugins/photoadjust/build.xml	(revision 30136)
+++ /applications/editors/josm/plugins/photoadjust/build.xml	(revision 30137)
@@ -59,18 +59,25 @@
     <target name="gettext-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}"/>
     </target>
     <target name="pot" description="Extract translatable strings from source." depends="gettext-init">
         <mkdir dir="po"/>
-        <gettext-extract keysFile="photoadjust.pot" poDirectory="po" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3">
+        <gettext-extract keysFile="${ant.project.name}.pot" poDirectory="po" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3">
             <fileset dir="src" includes="**/*.java"/>
         </gettext-extract>
+        <echo file="po/${ant.project.name}.pot" append="true">
+#. Plugin ${ant.project.name}
+#: build.xml:1
+msgid "${plugin.description}"
+msgstr ""
+</echo>
     </target>
-    <target name="pomerge" description="Merge extracted strings into language files." depends="gettext-init">
-        <gettext-merge keysFile="photoadjust.pot" poDirectory="po"/>
+    <target name="pomerge" description="Merge extracted strings into language files.">
+        <exec executable="perl">
+            <arg line="pomerge.pl"/>
+        </exec>
     </target>
     <target name="poimport" description="Import the PO files from the tarball launchpad-export.tar.gz exported from Launchpad.">
         <exec executable="perl">
-            <arg line="importpo.pl"/>
+            <arg line="poimport.pl"/>
         </exec>
     </target>
Index: plications/editors/josm/plugins/photoadjust/importpo.pl
===================================================================
--- /applications/editors/josm/plugins/photoadjust/importpo.pl	(revision 30136)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#! /usr/bin/perl -w
-###
-### importpo.pl - Import the translation from the tarball downloaded
-### from Launchpad.
-
-use strict;
-use File::Copy;
-use Cwd;
-use File::Spec::Functions;
-
-### Name of the tarball downloaded from Launchpad.
-my $tarball = "launchpad-export.tar.gz";
-### Temporary directory.
-my $workdir = "importpo";
-### Remove the temp. directory after the work is done (0/1)?
-my $rmworkdir = 1;
-### Destination directory relative to directory where this script was
-### started in.
-my $podir = "po";
-
-die "Tarball $tarball not found.\n" if (! -r $tarball);
-if (! -d $workdir) {
-  mkdir $workdir or die "Failed to create directory $workdir: $!";
-}
-copy($tarball, $workdir);
-my $startdir = getcwd();
-chdir $workdir;
-system "tar -xf $tarball";
-foreach my $lpponame (split("\n", `find po -name "*.po"`)) {
-  if ($lpponame =~ /([a-zA-Z_]+\.po)/) {
-    my $poname = $1;
-    copy($lpponame, catfile($startdir, $podir, $poname));
-  }
-}
-
-if ($rmworkdir) {
-  chdir $startdir;
-  system "rm -rf $workdir";
-}
Index: /applications/editors/josm/plugins/photoadjust/poimport.pl
===================================================================
--- /applications/editors/josm/plugins/photoadjust/poimport.pl	(revision 30137)
+++ /applications/editors/josm/plugins/photoadjust/poimport.pl	(revision 30137)
@@ -0,0 +1,85 @@
+#! /usr/bin/perl -w
+###
+### poimport.pl - Import the translation from the tarball downloaded
+###     from Launchpad.
+
+use strict;
+use File::Copy;
+use Cwd;
+use File::Spec::Functions;
+use File::Basename;
+
+### Name of the tarball downloaded from Launchpad.  Or download URL.
+### Or JOSM translation branch revision number.
+my $tarball = "launchpad-export.tar.gz";
+#$tarball = "http://launchpadlibrarian.net/159932691/launchpad-export.tar.gz";
+#$tarball = "http://bazaar.launchpad.net/~openstreetmap/josm/josm_trans/tarball/747";
+#$tarball = "747";
+### Temporary directory.  A unique directory name that is not used for
+### anything else.
+my $workdir = "importpo";
+### Remove the temp. directory after the work is done (0/1)?
+my $rmworkdir = 1;
+### Destination directory relative to directory where this script was
+### started in.
+my $podir = "po";
+
+### Check for arguments.  The only supported argument is the tarball.
+if ($#ARGV == 0) {
+  $tarball = $ARGV[0];
+}
+elsif ($#ARGV > 0) {
+  die "This script accepts only one argument.\n";
+}
+
+### Check for JOSM translation branch revision number.
+if ($tarball =~ m/^\d+$/) {
+  $tarball = "http://bazaar.launchpad.net/~openstreetmap/josm/josm_trans/"
+    . "tarball/" . $tarball;
+}
+
+### Check if tarball is a URL and download it.  The downloaded file
+### will not be removed and is available for a second import.
+my $downurl;
+if ($tarball =~ m,^http://.+/([^/]+)$,) {
+  ### URL: Download file.
+  $downurl = $tarball;
+  my $downfile = $1;
+  if ($downfile =~ m/^\d+$/) {
+    ### Download of revision number.
+    if ($tarball =~ m:/([^/]+)/tarball/(\d+)$:) {
+      $downfile = $1 . "_" . $2 . ".tar.gz";
+    }
+    else {
+      $downfile .= ".tar.gz";
+    }
+  }
+  print "Will download file $downfile from $downurl.\n";
+  system("wget -O $downfile $downurl") == 0 or die "wget failed: $?";
+  $tarball = $downfile;
+}
+
+die "Tarball $tarball not found.\n" if (! -r $tarball);
+if (! -d $workdir) {
+  mkdir $workdir or die "Failed to create work directory $workdir: $!";
+}
+copy($tarball, $workdir);
+my $startdir = getcwd();
+chdir $workdir;
+my $tarballfile = basename($tarball);
+system "tar -xf $tarballfile";
+print "Copy language files:";
+foreach my $lpponame (split("\n", `find . -name "*.po"`)) {
+  if ($lpponame =~ /([a-zA-Z_@]+)\.po/) {
+    my $lang = $1;
+    my $poname = $1 . ".po";
+    print " $lang";
+    copy($lpponame, catfile($startdir, $podir, $poname));
+  }
+}
+print "\n";
+
+if ($rmworkdir) {
+  chdir $startdir;
+  system "rm -rf $workdir";
+}
Index: /applications/editors/josm/plugins/photoadjust/pomerge.pl
===================================================================
--- /applications/editors/josm/plugins/photoadjust/pomerge.pl	(revision 30137)
+++ /applications/editors/josm/plugins/photoadjust/pomerge.pl	(revision 30137)
@@ -0,0 +1,36 @@
+#! /usr/bin/perl -w
+###
+### pomerge.pl - Run msgmerge with the files in the po directory and
+###     remove untranslated strings.
+
+use strict;
+use File::Spec::Functions;
+
+### Directory with PO files that are to be merged.
+my $podir = "po";
+### Path to POT file.
+my $potfile = catfile($podir, "photoadjust.pot");
+
+foreach my $pofile (split("\n", `find $podir -name "*.po"`)) {
+  ### Merge translation with template.
+  my $cmd = "msgmerge --quiet --update --backup=none $pofile $potfile";
+  system $cmd;
+
+  ### Get rid of all unneeded translations.  Fuzzy translations are
+  ### removed too.  msgattrib will not write an output file if nothing
+  ### is left.  We move the original file and delete it afterwards to
+  ### preserve only languages with translations.
+  my $potmp = $pofile . ".tmp";
+  rename $pofile, $potmp;
+  $cmd = "msgattrib --output-file=$pofile --translated --no-fuzzy --no-obsolete $potmp";
+  system $cmd;
+  unlink $potmp;
+  if (-z $pofile) {
+    ### The PO file might be empty if there are no translated strings.
+    unlink $pofile;
+  }
+  if (-e $pofile . "~") {
+    ### Remove the backup copy.
+    unlink $pofile . "~";
+  }
+}
