aboutsummaryrefslogtreecommitdiffstats
path: root/bin/generate_cobrand_po
blob: 1770de7c2d2b66b5536093eab652b8763892d7a6 (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
#!/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

my $cobrand = shift;

die "Please provide a cobrand name\n" unless $cobrand;

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");