Bug 4154 - Follow-up
[koha.git] / misc / translator / install-code.pl
1 #!/usr/bin/perl
2
3 use strict;
4
5 =head1 NAME
6
7 install-code.pl 
8
9 =head1 USAGE
10
11 Install templates and preferences for given language codes.
12
13 For example:
14
15    ./install-code fr-FR en-ES
16
17 creates templates for languages: fr-FR and en-ES
18
19 =cut
20
21
22 sub install_code {
23     my $code = shift;
24     opendir(PO_DIR, "po") or die "Unable to open po directory";
25     my @po_files = grep { /^$code-i-opac|^$code-i-staff/ } readdir PO_DIR;
26     closedir PO_DIR;
27     
28     foreach ( @po_files ) {
29         my ($interface) = /(staff|opac)/;
30         $interface =~ s/staff/intranet/;        
31         mkdir "../../koha-tmpl/$interface-tmpl/prog/$code";
32         print $_, " : ", $interface, "\n";
33         my $cmd = "./tmpl_process3.pl install -r " . 
34                   "-i ../../koha-tmpl/$interface-tmpl/prog/en/ " .
35                   "-o ../../koha-tmpl/$interface-tmpl/prog/$code " .
36                   "-s po/$_";
37         system $cmd;
38     }
39
40     system "./pref-trans install $code";
41 }
42
43
44 # Main
45
46 install_code ( $_ ) foreach ( @ARGV );
47