Skip to content

Instantly share code, notes, and snippets.

@mschmitt
Created April 24, 2012 04:56
Show Gist options
  • Save mschmitt/2476561 to your computer and use it in GitHub Desktop.
Save mschmitt/2476561 to your computer and use it in GitHub Desktop.
Transifex translation downloader
#!/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