Lines 22-36
use Modern::Perl;
Link Here
|
22 |
use C4::Context; |
22 |
use C4::Context; |
23 |
# WARNING: Any other tested YAML library fails to work properly in this |
23 |
# WARNING: Any other tested YAML library fails to work properly in this |
24 |
# script content |
24 |
# script content |
25 |
use YAML::Syck qw( LoadFile DumpFile ); |
25 |
# FIXME Really? |
|
|
26 |
use YAML::XS; |
26 |
use Locale::PO; |
27 |
use Locale::PO; |
27 |
use FindBin qw( $Bin ); |
28 |
use FindBin qw( $Bin ); |
28 |
use File::Basename; |
29 |
use File::Basename; |
29 |
use File::Path qw( make_path ); |
30 |
use File::Path qw( make_path ); |
30 |
use File::Copy; |
31 |
use File::Copy; |
31 |
|
32 |
|
32 |
$YAML::Syck::ImplicitTyping = 1; |
|
|
33 |
|
34 |
sub set_lang { |
33 |
sub set_lang { |
35 |
my ($self, $lang) = @_; |
34 |
my ($self, $lang) = @_; |
36 |
|
35 |
|
Lines 244-250
sub install_prefs {
Link Here
|
244 |
$self->{po} = Locale::PO->load_file_ashash($self->po_filename("-pref.po"), 'utf8'); |
243 |
$self->{po} = Locale::PO->load_file_ashash($self->po_filename("-pref.po"), 'utf8'); |
245 |
|
244 |
|
246 |
for my $file ( @{$self->{pref_files}} ) { |
245 |
for my $file ( @{$self->{pref_files}} ) { |
247 |
my $pref = LoadFile( $self->{path_pref_en} . "/$file" ); |
246 |
my $pref = YAML::XS::LoadFile( $self->{path_pref_en} . "/$file" ); |
248 |
|
247 |
|
249 |
my $translated_pref = { |
248 |
my $translated_pref = { |
250 |
map { |
249 |
map { |
Lines 258-264
sub install_prefs {
Link Here
|
258 |
|
257 |
|
259 |
my $file_trans = $self->{po_path_lang} . "/$file"; |
258 |
my $file_trans = $self->{po_path_lang} . "/$file"; |
260 |
print "Write $file\n" if $self->{verbose}; |
259 |
print "Write $file\n" if $self->{verbose}; |
261 |
DumpFile($file_trans, $translated_pref); |
260 |
YAML::XS::DumpFile($file_trans, $translated_pref); |
262 |
} |
261 |
} |
263 |
} |
262 |
} |
264 |
|
263 |
|
Lines 309-315
sub translate_yaml {
Link Here
|
309 |
|
308 |
|
310 |
my $po_ref = Locale::PO->load_file_ashash( $po_file ); |
309 |
my $po_ref = Locale::PO->load_file_ashash( $po_file ); |
311 |
|
310 |
|
312 |
my $dstyml = LoadFile( $srcyml ); |
311 |
my $dstyml = YAML::XS::LoadFile( $srcyml ); |
313 |
|
312 |
|
314 |
# translate fields in table rows |
313 |
# translate fields in table rows |
315 |
my @tables = @{ $dstyml->{'tables'} }; |
314 |
my @tables = @{ $dstyml->{'tables'} }; |
Lines 402-408
sub install_installer {
Link Here
|
402 |
if ( $file =~ /yml$/ ) { |
401 |
if ( $file =~ /yml$/ ) { |
403 |
my $translated_yaml = translate_yaml( $self, $target, "$intradir/$dir/$file" ); |
402 |
my $translated_yaml = translate_yaml( $self, $target, "$intradir/$dir/$file" ); |
404 |
open(my $fh, ">:encoding(UTF-8)", "$intradir/$tdir/$file"); |
403 |
open(my $fh, ">:encoding(UTF-8)", "$intradir/$tdir/$file"); |
405 |
DumpFile( $fh, $translated_yaml ); |
404 |
YAML::XS::DumpFile( $fh, $translated_yaml ); |
406 |
close($fh); |
405 |
close($fh); |
407 |
} else { |
406 |
} else { |
408 |
File::Copy::copy( "$intradir/$dir/$file", "$intradir/$tdir/$file" ); |
407 |
File::Copy::copy( "$intradir/$dir/$file", "$intradir/$tdir/$file" ); |