[Zanata] Fix bugs in po to nested json toolchain
This commit is contained in:
parent
1c8e0061b5
commit
6839065ece
@ -3,5 +3,5 @@ for i in po/*.po
|
|||||||
do
|
do
|
||||||
j=$(echo $i | cut -d '.' -f 1 | cut -d '/' -f 2)
|
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
|
po2json -i $i -t locale/en.json --progress none | ./.renest_json.pl > po/$j.json
|
||||||
mv po/$j.json locale/$j.json
|
|
||||||
done
|
done
|
||||||
|
mv po/*.json locale/
|
||||||
|
@ -14,11 +14,11 @@ while (defined(my $line = <STDIN>)) {
|
|||||||
$old_json .= $line;
|
$old_json .= $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
$old_json = decode_json($old_json);
|
$old_json = $json->decode($old_json);
|
||||||
for my $key (keys %{$old_json}) {
|
for my $key (keys %{$old_json}) {
|
||||||
$key =~ m/^([^.]*)\.(.*)$/;
|
my $index = index($key, '.');
|
||||||
my $real_key = $1;
|
my $real_key = substr($key, 0, $index++);
|
||||||
my $trad_key = $2;
|
my $trad_key = substr($key, $index);
|
||||||
|
|
||||||
$new_json->{$real_key}->{$trad_key} = $old_json->{$key} if $old_json->{$key};
|
$new_json->{$real_key}->{$trad_key} = $old_json->{$key} if $old_json->{$key};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user