Commit 65d8fd96 authored by Luc Didry's avatar Luc Didry
Browse files

[zanata] Use en translation string if not translated

parent 05e9ea15
#!/bin/bash
po2json -i po/en.po -t locale/en.json --progress none -o po/default.json
for i in po/*.po
do
j=$(echo $i | cut -d '.' -f 1 | cut -d '/' -f 2)
po2json -i $i -t locale/en.json --progress none | ./.renest_json.pl > po/$j.json
mv po/$j.json locale/
done
mv po/*.json locale/
......@@ -3,10 +3,20 @@ use strict;
use warnings;
use JSON;
#use Hash::Merge::Simple qw(merge);
my $json = JSON->new->utf8->space_before(0)->space_after(1)->indent(4)->canonical(1);
my $en_file = 'po/default.json';
my $en;
{
open my $fh, '<', $en_file or die;
local $/ = undef;
$en = <$fh>;
close $fh;
}
$en = $json->decode($en);
my $new_json = {};
my $old_json = '';
......@@ -20,7 +30,11 @@ for my $key (keys %{$old_json}) {
my $real_key = substr($key, 0, $index++);
my $trad_key = substr($key, $index);
$new_json->{$real_key}->{$trad_key} = $old_json->{$key} if $old_json->{$key};
if ($old_json->{$key}) {
$new_json->{$real_key}->{$trad_key} = $old_json->{$key};
} else {
$new_json->{$real_key}->{$trad_key} = $en->{$key};
}
}
print $json->encode($new_json);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment