[Zanata] Fix bugs in po to nested json toolchain

This commit is contained in:
Luc Didry 2018-02-27 17:10:34 +01:00
parent 1c8e0061b5
commit 6839065ece
2 changed files with 5 additions and 5 deletions

View File

@ -3,5 +3,5 @@ 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/$j.json
done
mv po/*.json locale/

View File

@ -14,11 +14,11 @@ while (defined(my $line = <STDIN>)) {
$old_json .= $line;
}
$old_json = decode_json($old_json);
$old_json = $json->decode($old_json);
for my $key (keys %{$old_json}) {
$key =~ m/^([^.]*)\.(.*)$/;
my $real_key = $1;
my $trad_key = $2;
my $index = index($key, '.');
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};
}