blob: 8e62230ae0ace5b93a4a00a660851bfb5ed9b275 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/usr/bin/env perl
use strict;
=for instructions
This script generates a po file that contains only the strings related to a cobrand.
Its purpose is to avoid having lots of cobrand specific strings in the
main FixMyStreet po file confusing translators. Once this is run the
generated po file can be used to translate the strings. The po files
with the translation should then be placed in the relevant language
directories and merge_cobrand_po run which will merge these with
the main FixMyStreet po files
=cut
use File::Basename qw(dirname);
use File::Spec;
my $cobrand = shift;
die "Please provide a cobrand name\n" unless $cobrand;
my $d = dirname(dirname(File::Spec->rel2abs($0)));
chdir $d;
# Install required code if needed
system("vendor/bin/carton install --path local-gettext --cpanfile locale/cpanfile --deployment");
$ENV{PATH} = "local-gettext/bin:$ENV{PATH}";
$ENV{PERL5LIB} = "local-gettext/lib/perl5:local/lib/perl5";
my $cobrand_lc = lc( $cobrand );
my $PO = "locale/$cobrand.po";
my $cobrand_module = "perllib/FixMyStreet/Cobrand/$cobrand.pm";
my $web_templates = "templates/web/$cobrand_lc/";
my $opts = '';
if ( -e $cobrand_module ) {
$opts .= " $cobrand_module";
}
if ( -e -d $web_templates ) {
$opts .= " --directory $web_templates";
}
# first we get the strings from the cobrand
system("xgettext.pl --gnu-gettext --verbose --output $PO --plugin perl=* --plugin tt2 $opts");
# now replace the template header elements
system("bin/update_po_header.bash $PO");
|