Lines 208-216
sub get_po_from_prefs {
Link Here
|
208 |
|
208 |
|
209 |
sub save_po { |
209 |
sub save_po { |
210 |
my $self = shift; |
210 |
my $self = shift; |
|
|
211 |
my $silent = shift; |
211 |
# Write .po entries into a file put in Koha standard po directory |
212 |
# Write .po entries into a file put in Koha standard po directory |
212 |
Locale::PO->save_file_fromhash( $self->po_filename, $self->{po} ); |
213 |
Locale::PO->save_file_fromhash( $self->po_filename, $self->{po} ); |
213 |
print "Saved in file: ", $self->po_filename, "\n"; |
214 |
if ($silent) { |
|
|
215 |
print "Saved in file: ", $self->po_filename, "\n"; |
216 |
} |
214 |
} |
217 |
} |
215 |
|
218 |
|
216 |
|
219 |
|
Lines 235-249
sub get_po_merged_with_en {
Link Here
|
235 |
|
238 |
|
236 |
sub update_prefs { |
239 |
sub update_prefs { |
237 |
my $self = shift; |
240 |
my $self = shift; |
238 |
print "Update '", $self->{lang}, |
241 |
my $silent = shift; |
239 |
"' preferences .po file from 'en' .pref files\n"; |
242 |
unless ($silent) { |
|
|
243 |
print "Update '", $self->{lang}, |
244 |
"' preferences .po file from 'en' .pref files\n"; |
245 |
} |
240 |
$self->get_po_merged_with_en(); |
246 |
$self->get_po_merged_with_en(); |
241 |
$self->save_po(); |
247 |
$self->save_po($silent); |
242 |
} |
248 |
} |
243 |
|
249 |
|
244 |
|
250 |
|
245 |
sub install_prefs { |
251 |
sub install_prefs { |
246 |
my $self = shift; |
252 |
my $self = shift; |
|
|
253 |
my $silent = shift; |
247 |
|
254 |
|
248 |
unless ( -r $self->{po_path_lang} ) { |
255 |
unless ( -r $self->{po_path_lang} ) { |
249 |
print "Koha directories hierarchy for ", $self->{lang}, " must be created first\n"; |
256 |
print "Koha directories hierarchy for ", $self->{lang}, " must be created first\n"; |
Lines 281-287
sub install_prefs {
Link Here
|
281 |
$pref->{$tab} = $ntab; |
288 |
$pref->{$tab} = $ntab; |
282 |
} |
289 |
} |
283 |
my $file_trans = $self->{po_path_lang} . "/$file"; |
290 |
my $file_trans = $self->{po_path_lang} . "/$file"; |
284 |
print "Write $file\n"; |
291 |
unless ($silent) { |
|
|
292 |
print "Write $file\n"; |
293 |
} |
285 |
open my $fh, ">", $file_trans; |
294 |
open my $fh, ">", $file_trans; |
286 |
print $fh Dump($pref); |
295 |
print $fh Dump($pref); |
287 |
} |
296 |
} |
Lines 290-308
sub install_prefs {
Link Here
|
290 |
|
299 |
|
291 |
sub install_tmpl { |
300 |
sub install_tmpl { |
292 |
my $self = shift; |
301 |
my $self = shift; |
293 |
|
302 |
my $silent = shift; |
294 |
print |
303 |
unless ($silent) { |
295 |
"Install templates\n"; |
304 |
print "Install templates\n"; |
|
|
305 |
} |
296 |
while ( my ($interface, $tmpl) = each %{$self->{interface}} ) { |
306 |
while ( my ($interface, $tmpl) = each %{$self->{interface}} ) { |
297 |
print |
307 |
unless ($silent) { |
298 |
" Install templates '$interface\n", |
308 |
print |
299 |
" From: $tmpl->{dir}/en/\n", |
309 |
" Install templates '$interface\n", |
300 |
" To : $tmpl->{dir}/$self->{lang}\n", |
310 |
" From: $tmpl->{dir}/en/\n", |
301 |
" With: $self->{path_po}/$self->{lang}$tmpl->{suffix}\n"; |
311 |
" To : $tmpl->{dir}/$self->{lang}\n", |
|
|
312 |
" With: $self->{path_po}/$self->{lang}$tmpl->{suffix}\n"; |
313 |
} |
302 |
my $lang_dir = "$tmpl->{dir}/$self->{lang}"; |
314 |
my $lang_dir = "$tmpl->{dir}/$self->{lang}"; |
303 |
mkdir $lang_dir unless -d $lang_dir; |
315 |
mkdir $lang_dir unless -d $lang_dir; |
304 |
system |
316 |
system |
305 |
"$self->{translator_path}/tmpl_process3.pl install " . |
317 |
"$self->{translator_path}/tmpl_process3.pl $silent install " . |
306 |
"-i $tmpl->{dir}/en/ " . |
318 |
"-i $tmpl->{dir}/en/ " . |
307 |
"-o $tmpl->{dir}/$self->{lang} ". |
319 |
"-o $tmpl->{dir}/$self->{lang} ". |
308 |
"-s $self->{path_po}/$self->{lang}$tmpl->{suffix} -r" |
320 |
"-s $self->{path_po}/$self->{lang}$tmpl->{suffix} -r" |
Lines 312-329
sub install_tmpl {
Link Here
|
312 |
|
324 |
|
313 |
sub update_tmpl { |
325 |
sub update_tmpl { |
314 |
my $self = shift; |
326 |
my $self = shift; |
|
|
327 |
my $silent = shift; |
315 |
|
328 |
|
316 |
print |
329 |
unless ($silent) { |
317 |
"Update templates\n"; |
330 |
print "Update templates\n"; |
|
|
331 |
} |
318 |
while ( my ($interface, $tmpl) = each %{$self->{interface}} ) { |
332 |
while ( my ($interface, $tmpl) = each %{$self->{interface}} ) { |
319 |
print |
333 |
unless ($silent) { |
320 |
" Update templates '$interface'\n", |
334 |
print |
321 |
" From: $tmpl->{dir}/en/\n", |
335 |
" Update templates '$interface'\n", |
322 |
" To : $self->{path_po}/$self->{lang}$tmpl->{suffix}\n"; |
336 |
" From: $tmpl->{dir}/en/\n", |
|
|
337 |
" To : $self->{path_po}/$self->{lang}$tmpl->{suffix}\n"; |
338 |
} |
323 |
my $lang_dir = "$tmpl->{dir}/$self->{lang}"; |
339 |
my $lang_dir = "$tmpl->{dir}/$self->{lang}"; |
324 |
mkdir $lang_dir unless -d $lang_dir; |
340 |
mkdir $lang_dir unless -d $lang_dir; |
325 |
system |
341 |
system |
326 |
"$self->{translator_path}/tmpl_process3.pl update " . |
342 |
"$self->{translator_path}/tmpl_process3.pl update $silent " . |
327 |
"-i $tmpl->{dir}/en/ " . |
343 |
"-i $tmpl->{dir}/en/ " . |
328 |
"-s $self->{path_po}/$self->{lang}$tmpl->{suffix} -r" |
344 |
"-s $self->{path_po}/$self->{lang}$tmpl->{suffix} -r" |
329 |
} |
345 |
} |
Lines 340-355
sub create_prefs {
Link Here
|
340 |
|
356 |
|
341 |
sub create_tmpl { |
357 |
sub create_tmpl { |
342 |
my $self = shift; |
358 |
my $self = shift; |
|
|
359 |
my $silent = shift; |
343 |
|
360 |
|
344 |
print |
361 |
unless ($silent) { |
345 |
"Create templates\n"; |
362 |
print "Create templates\n"; |
|
|
363 |
} |
346 |
while ( my ($interface, $tmpl) = each %{$self->{interface}} ) { |
364 |
while ( my ($interface, $tmpl) = each %{$self->{interface}} ) { |
|
|
365 |
unless ($silent) { |
347 |
print |
366 |
print |
348 |
" Create templates .po files for '$interface'\n", |
367 |
" Create templates .po files for '$interface'\n", |
349 |
" From: $tmpl->{dir}/en/\n", |
368 |
" From: $tmpl->{dir}/en/\n", |
350 |
" To : $self->{path_po}/$self->{lang}$tmpl->{suffix}\n"; |
369 |
" To : $self->{path_po}/$self->{lang}$tmpl->{suffix}\n"; |
|
|
370 |
} |
351 |
system |
371 |
system |
352 |
"$self->{translator_path}/tmpl_process3.pl create " . |
372 |
"$self->{translator_path}/tmpl_process3.pl $silent create " . |
353 |
"-i $tmpl->{dir}/en/ " . |
373 |
"-i $tmpl->{dir}/en/ " . |
354 |
"-s $self->{path_po}/$self->{lang}$tmpl->{suffix} -r" |
374 |
"-s $self->{path_po}/$self->{lang}$tmpl->{suffix} -r" |
355 |
} |
375 |
} |
Lines 358-366
sub create_tmpl {
Link Here
|
358 |
|
378 |
|
359 |
sub install { |
379 |
sub install { |
360 |
my $self = shift; |
380 |
my $self = shift; |
|
|
381 |
my $silent = shift; |
361 |
return unless $self->{lang}; |
382 |
return unless $self->{lang}; |
362 |
$self->install_tmpl() unless $self->{pref_only}; |
383 |
$self->install_tmpl($silent) unless $self->{pref_only}; |
363 |
$self->install_prefs(); |
384 |
$self->install_prefs($silent); |
364 |
} |
385 |
} |
365 |
|
386 |
|
366 |
|
387 |
|
Lines 375-394
sub get_all_langs {
Link Here
|
375 |
|
396 |
|
376 |
sub update { |
397 |
sub update { |
377 |
my $self = shift; |
398 |
my $self = shift; |
|
|
399 |
my $silent = shift; |
378 |
my @langs = $self->{lang} ? ($self->{lang}) : $self->get_all_langs(); |
400 |
my @langs = $self->{lang} ? ($self->{lang}) : $self->get_all_langs(); |
379 |
for my $lang ( @langs ) { |
401 |
for my $lang ( @langs ) { |
380 |
$self->set_lang( $lang ); |
402 |
$self->set_lang( $lang ); |
381 |
$self->update_tmpl() unless $self->{pref_only}; |
403 |
$self->update_tmpl($silent) unless $self->{pref_only}; |
382 |
$self->update_prefs(); |
404 |
$self->update_prefs($silent); |
383 |
} |
405 |
} |
384 |
} |
406 |
} |
385 |
|
407 |
|
386 |
|
408 |
|
387 |
sub create { |
409 |
sub create { |
388 |
my $self = shift; |
410 |
my $self = shift; |
|
|
411 |
my $silent = shift; |
389 |
return unless $self->{lang}; |
412 |
return unless $self->{lang}; |
390 |
$self->create_tmpl() unless $self->{pref_only}; |
413 |
$self->create_tmpl($silent) unless $self->{pref_only}; |
391 |
$self->create_prefs(); |
414 |
$self->create_prefs($silent); |
392 |
} |
415 |
} |
393 |
|
416 |
|
394 |
|
417 |
|