2018-02-26 11:49:15 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use JSON;
|
|
|
|
|
|
|
|
my $json = JSON->new->utf8->space_before(0)->space_after(1)->indent(4)->canonical(1);
|
|
|
|
|
2018-03-20 17:09:02 +01:00
|
|
|
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);
|
|
|
|
|
2018-02-26 11:49:15 +01:00
|
|
|
my $new_json = {};
|
|
|
|
my $old_json = '';
|
|
|
|
|
|
|
|
while (defined(my $line = <STDIN>)) {
|
|
|
|
$old_json .= $line;
|
|
|
|
}
|
|
|
|
|
2018-02-27 17:10:34 +01:00
|
|
|
$old_json = $json->decode($old_json);
|
2018-02-26 11:49:15 +01:00
|
|
|
for my $key (keys %{$old_json}) {
|
2018-02-27 17:10:34 +01:00
|
|
|
my $index = index($key, '.');
|
|
|
|
my $real_key = substr($key, 0, $index++);
|
|
|
|
my $trad_key = substr($key, $index);
|
2018-02-26 11:49:15 +01:00
|
|
|
|
2018-03-20 17:09:02 +01:00
|
|
|
if ($old_json->{$key}) {
|
|
|
|
$new_json->{$real_key}->{$trad_key} = $old_json->{$key};
|
|
|
|
} else {
|
|
|
|
$new_json->{$real_key}->{$trad_key} = $en->{$key};
|
|
|
|
}
|
2018-02-26 11:49:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
print $json->encode($new_json);
|