Changeset 27020 in osm for applications/editors
- Timestamp:
- 2011-11-06T17:14:16+01:00 (13 years ago)
- Location:
- applications/editors/josm/i18n
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/i18n
- Property svn:ignore
-
old new 1 1 build 2 launchpad.pl_credits
-
- Property svn:ignore
-
applications/editors/josm/i18n/README.TXT
r26931 r27020 17 17 Call "ant test". 18 18 19 5) Upload POT file to launchpad: 20 Call "./launchpad.pl upload". You need to set login information (see file how to do) or enter them when running. 21 22 6) Request launchpad po file download: 23 Call "./launchpad.pl download". You need to set login information (see file how to do) or enter them when running. 24 19 25 NOTE: 20 26 a) Your repositories should not have any local modifications which modify string elements! -
applications/editors/josm/i18n/launchpad.pl
r26928 r27020 3 3 use strict; 4 4 5 my ($user, $pwd); 6 7 # Three ways to handle login data: 8 # Enter data directly in these two lines (Be careful witn svn checkin later!) 9 # create a file "uploadpot.pl_credits" containing the two lines with proper values 10 # leave credits empty and enter them on runtime 11 $user = ''; 12 $pwd = ''; 13 14 # list of supported languages 5 15 my %lang = map {$_ => 1} ( 6 16 "ar", "bg", "cs", "da", "de", "el", "en_AU", "en_GB", … … 16 26 if($#ARGV != 0) 17 27 { 18 warn "URL not given (try Launchpad download URL or \"bzr\")." 28 warn "No argument given (try Launchpad download URL, \"bzr\", \"bzronly\", \"upload\" or \"download\")."; 29 system "ant"; 30 makeupload(); 19 31 } 20 32 elsif($ARGV[0] eq "bzr" || $ARGV[0] eq "bzronly") … … 26 38 copypo("build/josm_trans/josm"); 27 39 system "rm -rv build/josm_trans"; 28 exit(0) if $ARGV[0] eq "bzronly"; 40 if($ARGV[0] ne "bzronly") 41 { 42 system "ant"; 43 makeupload(); 44 } 45 } 46 elsif($ARGV[0] eq "upload") 47 { 48 potupload(); 49 } 50 elsif($ARGV[0] eq "download") 51 { 52 podownload(); 29 53 } 30 54 else … … 38 62 copypo("build/josm_trans"); 39 63 system "rm -rv build/josm_trans"; 40 } 41 42 system "ant"; 43 if($upload) 44 { 45 my $outdate = `date -u +"%Y-%m-%dT%H_%M_%S"`; 46 chomp $outdate; 47 mkdir "build/josm"; 48 system "cp po/*.po po/josm.pot build/josm"; 49 chdir "build"; 50 if(!$count) 51 { 52 system "tar -cjf ../launchpad_upload_josm_$outdate.tar.bz2 josm"; 53 } 54 else 55 { 56 my @files = sort glob("josm/*.po"); 57 my $num = 1; 58 while($#files >= 0) 59 { 60 my @f = splice(@files, 0, $count); 61 system "tar -cjf ../launchpad_upload_josm_${outdate}_$num.tar.bz2 josm/josm.pot ".join(" ",@f); 62 ++$num; 63 } 64 } 65 system "rm -rv josm"; 66 chdir ".."; 64 system "ant"; 65 makeupload(); 66 } 67 68 sub makeupload 69 { 70 if($upload) 71 { 72 my $outdate = `date -u +"%Y-%m-%dT%H_%M_%S"`; 73 chomp $outdate; 74 mkdir "build/josm"; 75 system "cp po/*.po po/josm.pot build/josm"; 76 chdir "build"; 77 if(!$count) 78 { 79 system "tar -cjf ../launchpad_upload_josm_$outdate.tar.bz2 josm"; 80 } 81 else 82 { 83 my @files = sort glob("josm/*.po"); 84 my $num = 1; 85 while($#files >= 0) 86 { 87 my @f = splice(@files, 0, $count); 88 system "tar -cjf ../launchpad_upload_josm_${outdate}_$num.tar.bz2 josm/josm.pot ".join(" ",@f); 89 ++$num; 90 } 91 } 92 system "rm -rv josm"; 93 chdir ".."; 94 } 67 95 } 68 96 … … 72 100 foreach my $name (split("\n", `find $path -name "*.po"`)) 73 101 { 74 $name =~ /([a-zA-Z_]+)\.po/; 75 if($lang{$1}) 76 { 77 system "cp -v $name po/$1.po"; 78 } 79 elsif($cleanall) 80 { 81 local $/; undef $/; 82 open FILE,"<",$name or die; 83 my $x = <FILE>; 84 close FILE; 85 $x =~ s/\n\n.*$/\n/s; 86 open FILE,">","po/$1.po" or die; 87 print FILE $x; 88 close FILE; 89 } 90 } 91 } 102 $name =~ /([a-zA-Z_]+)\.po/; 103 if($lang{$1}) 104 { 105 system "cp -v $name po/$1.po"; 106 } 107 elsif($cleanall) 108 { 109 local $/; undef $/; 110 open FILE,"<",$name or die; 111 my $x = <FILE>; 112 close FILE; 113 $x =~ s/\n\n.*$/\n/s; 114 open FILE,">","po/$1.po" or die; 115 print FILE $x; 116 close FILE; 117 } 118 } 119 } 120 121 sub dologin 122 { 123 require WWW::Mechanize; 124 125 my $mech = WWW::Mechanize->new("agent" => "JOSM_Launchpad/1.0"); 126 127 #$mech->add_handler("request_send" => sub { 128 # my($request, $ua, $h) = @_; 129 # printf "FORM: %s\n", $request->content(); 130 # return undef; 131 #}); 132 $mech->get("https://translations.launchpad.net/josm/trunk/+login"); 133 #print $mech->status() ." - ". $mech->uri()."\n"; 134 $mech->submit_form(form_number => 1); 135 getcredits(); 136 #print $mech->status() ." - ". $mech->uri()."\n"; 137 $mech->submit_form(with_fields => {"email" => $user, "password" => $pwd}); 138 #$mech->dump_headers(); 139 #print $mech->status() ." - ". $mech->uri()."\n"; 140 #print $mech->content(); 141 my $form = $mech->form_name("decideform"); 142 my %par = ("yes" => ""); # We need to add "yes" or it does not work 143 foreach my $p ($form->param) 144 { 145 $par{$p} = $form->value($p); 146 } 147 $mech->post($form->action, \%par); 148 #$mech->dump_headers(); 149 #print $mech->content(); 150 #print $mech->status() ." - ". $mech->uri()."\n"; 151 #$mech->dump_forms(); 152 return $mech; 153 } 154 155 sub potupload 156 { 157 my $mech = dologin(); 158 $mech->get("https://translations.launchpad.net/josm/trunk/+translations-upload"); 159 chdir("po"); 160 $mech->submit_form(with_fields => {"file" => "josm.pot"}); 161 chdir(".."); 162 } 163 164 sub podownload 165 { 166 my $mech = dologin(); 167 $mech->get("https://translations.launchpad.net/josm/trunk/+export"); 168 $mech->submit_form(with_fields => {"format" => "PO"}); 169 if(!($mech->content() =~ /receive an email shortly/)) 170 { 171 warn "Error requesting file\n"; 172 } 173 } 174 175 sub getcredits 176 { 177 if(!$user || !$pwd) 178 { 179 require Term::ReadKey; 180 local undef $/; 181 if(open FILE, "launchpad.pl_credits") 182 { 183 eval <FILE>; 184 close FILE; 185 } 186 187 if(!$user) 188 { 189 Term::ReadKey::ReadMode(4); # Turn off controls keys 190 printf("Enter username: "); 191 for(;;) 192 { 193 my $c = getc(); 194 print $c; 195 last if $c eq "\n"; 196 $user .= $c; 197 } 198 Term::ReadKey::ReadMode(0); 199 } 200 201 if(!$pwd) 202 { 203 Term::ReadKey::ReadMode(4); # Turn off controls keys 204 printf("Enter password: "); 205 for(;;) 206 { 207 my $c = getc(); 208 last if $c eq "\n"; 209 print "*"; 210 $pwd .= $c; 211 } 212 print "\n"; 213 Term::ReadKey::ReadMode(0); 214 } 215 } 216 }
Note:
See TracChangeset
for help on using the changeset viewer.