Changeset 30137 in osm for applications/editors/josm/plugins/photoadjust/poimport.pl
- Timestamp:
- 2013-12-19T17:04:32+01:00 (13 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/photoadjust/poimport.pl
r30130 r30137 1 1 #! /usr/bin/perl -w 2 2 ### 3 ### importpo.pl - Import the translation from the tarball downloaded4 ### from Launchpad. 3 ### poimport.pl - Import the translation from the tarball downloaded 4 ### from Launchpad. 5 5 6 6 use strict; … … 8 8 use Cwd; 9 9 use File::Spec::Functions; 10 use File::Basename; 10 11 11 ### Name of the tarball downloaded from Launchpad. 12 ### Name of the tarball downloaded from Launchpad. Or download URL. 13 ### Or JOSM translation branch revision number. 12 14 my $tarball = "launchpad-export.tar.gz"; 13 ### Temporary directory. 15 #$tarball = "http://launchpadlibrarian.net/159932691/launchpad-export.tar.gz"; 16 #$tarball = "http://bazaar.launchpad.net/~openstreetmap/josm/josm_trans/tarball/747"; 17 #$tarball = "747"; 18 ### Temporary directory. A unique directory name that is not used for 19 ### anything else. 14 20 my $workdir = "importpo"; 15 21 ### Remove the temp. directory after the work is done (0/1)? … … 19 25 my $podir = "po"; 20 26 27 ### Check for arguments. The only supported argument is the tarball. 28 if ($#ARGV == 0) { 29 $tarball = $ARGV[0]; 30 } 31 elsif ($#ARGV > 0) { 32 die "This script accepts only one argument.\n"; 33 } 34 35 ### Check for JOSM translation branch revision number. 36 if ($tarball =~ m/^\d+$/) { 37 $tarball = "http://bazaar.launchpad.net/~openstreetmap/josm/josm_trans/" 38 . "tarball/" . $tarball; 39 } 40 41 ### Check if tarball is a URL and download it. The downloaded file 42 ### will not be removed and is available for a second import. 43 my $downurl; 44 if ($tarball =~ m,^http://.+/([^/]+)$,) { 45 ### URL: Download file. 46 $downurl = $tarball; 47 my $downfile = $1; 48 if ($downfile =~ m/^\d+$/) { 49 ### Download of revision number. 50 if ($tarball =~ m:/([^/]+)/tarball/(\d+)$:) { 51 $downfile = $1 . "_" . $2 . ".tar.gz"; 52 } 53 else { 54 $downfile .= ".tar.gz"; 55 } 56 } 57 print "Will download file $downfile from $downurl.\n"; 58 system("wget -O $downfile $downurl") == 0 or die "wget failed: $?"; 59 $tarball = $downfile; 60 } 61 21 62 die "Tarball $tarball not found.\n" if (! -r $tarball); 22 63 if (! -d $workdir) { 23 mkdir $workdir or die "Failed to create directory $workdir: $!"; 64 mkdir $workdir or die "Failed to create work directory $workdir: $!"; 24 65 } 25 66 copy($tarball, $workdir); 26 67 my $startdir = getcwd(); 27 68 chdir $workdir; 28 system "tar -xf $tarball"; 29 foreach my $lpponame (split("\n", `find po -name "*.po"`)) { 30 if ($lpponame =~ /([a-zA-Z_]+\.po)/) { 31 my $poname = $1; 69 my $tarballfile = basename($tarball); 70 system "tar -xf $tarballfile"; 71 print "Copy language files:"; 72 foreach my $lpponame (split("\n", `find . -name "*.po"`)) { 73 if ($lpponame =~ /([a-zA-Z_@]+)\.po/) { 74 my $lang = $1; 75 my $poname = $1 . ".po"; 76 print " $lang"; 32 77 copy($lpponame, catfile($startdir, $podir, $poname)); 33 78 } 34 79 } 80 print "\n"; 35 81 36 82 if ($rmworkdir) {
Note:
See TracChangeset
for help on using the changeset viewer.
