Created
April 24, 2012 04:56
-
-
Save mschmitt/2476561 to your computer and use it in GitHub Desktop.
Transifex translation downloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use diagnostics; | |
use LWP::Simple; | |
use JSON; | |
my $proj = 'friendica'; | |
my $lang = 'eo'; | |
my $auth = 'user:password'; | |
my $fmt_list = 'https://%[email protected]/api/2/project/%s/resources/'; | |
my $fmt_trans = 'https://%[email protected]/api/2/project/%s/resource/%s/translation/%s/'; | |
my $url_resources = sprintf($fmt_list, $auth, $proj); | |
my $resources = decode_json(get($url_resources)); | |
foreach(@{$resources}){ | |
my $res = $_; | |
my $slug = $res->{'slug'}; | |
my $name = $res->{'name'}; | |
my $url_trans = sprintf($fmt_trans, $auth, $proj, $slug, $lang); | |
my $resource = decode_json(get($url_trans)); | |
my $content = $resource->{'content'}; | |
open my $fh_out, ">/tmp/$name"; | |
binmode $fh_out, ':utf8'; | |
print $fh_out $content; | |
close $fh_out; | |
print "/tmp/$name\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment