aboutsummaryrefslogtreecommitdiffstats
path: root/bin/gettext-extract
blob: 75b95f152d92ec7c5ffe558bfb87ee5eff288492 (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
49
50
51
52
53
#!/bin/bash
#
# fixmystreet/bin/gettext-extract
# Generate English language .po files from the source code and email templates,
# for FixMyStreet. Writes the output to appropriate .po files in locale/.
#
# Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/

if [ -e ../../locale ]
then
    cd ../../
else if [ -e ../locale ]
then
    cd ../
else if [ -e locale ]
then
    cd .
else 
    echo "Please run with current directory fixmystreet/bin"
    exit 1
fi
fi
fi

# File to write to, clear it to start with
PO=locale/FixMyStreetMobileApp.po
rm -f $PO

# Extract from Perl
xgettext.pl --gnu-gettext --verbose --output $PO --plugin perl=* --plugin tt2 --directory templates

# Fix headers
# no such thing as tempfile on OS X
TEMP=`tempfile 2>/dev/null || mktemp /tmp/gettext-extract.XXXXXX`
NOW=`date +"%Y-%m-%d %H:%M%z"`
# strictly POSIX sed on e.g. OS X doesn't let you used \n in replacements so we do this
nl=$'\n';
cat $PO | sed "
        s/SOME DESCRIPTIVE TITLE/FixMyStreet mobile app original .po file, autogenerated by gettext-extract/;
        s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2013 UK Citizens Online Democracy/;
        s/PACKAGE package/main FixMyStreet code/;
        s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Struan Donald <struan@mysociety.org>, 2013./;

        s/PACKAGE VERSION/1.0\\\n\"\\$nl\"Report-Msgid-Bugs-To: struan@mysociety.org/;
        s/POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE/POT-Creation-Date: $NOW/;
        s/LL@li.org/team@fixmystreet.com/;
        s/charset=CHARSET/charset=UTF-8/;
        s/8bit/8bit\\\n\"\\$nl\"Plural-Forms: nplurals=2; plural=n != 1;/;
" >> $TEMP
mv $TEMP $PO

echo "$( bin/gettext-nget-patch )" >> $PO