Koha/misc/translate_json.pl
Jonathan Druart 74be73121e
Bug 32030: Update I18N
Note that we are adding an extra space for id and counter, otherwise
they got removed in favor of the "simple" string.
  { Agreement: Agreement }
replaced
  { Agreement: { id: ..., counter: ... } }

Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-08 09:44:02 -03:00

31 lines
878 B
Perl

use Modern::Perl;
use File::Slurp qw( read_file );
use JSON qw( from_json to_json );
my $json = read_file('koha-tmpl/intranet-tmpl/prog/js/vue/locales/en.json');
my $h = from_json($json);
my $translated = {};
while (my ($k, $v) = each %$h ){
if ( ref($v) ) {
for my $kk ( keys %$v ) {
( my $vv = $k ) =~ s|\s*$||;
if ( $kk eq 'counter' ) {
$translated->{$k}->{counter} = "$vv \%{counter}";
} elsif ( $kk eq 'id' ) {
$translated->{$k}->{id} = "$vv #\%{id}";
} else {
die "INVALID structure with key " . $kk;
}
}
} else {
if ( $k =~ /^There are no/ ) {
$translated->{$k} = "$k."
}
else {
$translated->{$k} = $k
}
}
}
say to_json($translated, {utf8 => 1, pretty => 1, canonical => 1});