]> git.mxchange.org Git - friendica.git/blob - util/run_xgettext.sh
Bugfixes: 1. When posting shared feeds to Diaspora, the link vanished/2. The profile...
[friendica.git] / util / run_xgettext.sh
1 #!/bin/bash
2 FULLPATH=$(dirname $(readlink -f "$0"))
3
4 ADDONMODE=
5 ADDONNAME=
6 if [ "$1" == "--addon" -o "$1" == "-a" ]
7 then
8         ADDONMODE=1
9         if [ -z $2 ]; then echo -e "ERROR: missing addon name\n\nrun_xgettext.sh -a <addonname>"; exit 1; fi
10         ADDONNAME=$2
11         if [ ! -d "$FULLPATH/../addon/$ADDONNAME" ]; then echo "ERROR: addon '$ADDONNAME' not found"; exit 2; fi
12 fi
13
14 if [ $ADDONMODE ]
15 then 
16         cd "$FULLPATH/../addon/$ADDONNAME"
17         mkdir -p "$FULLPATH/../addon/$ADDONNAME/lang/C"
18         OUTFILE="$FULLPATH/../addon/$ADDONNAME/lang/C/messages.po"
19         FINDSTARTDIR="."
20         FINDOPTS=
21 else
22         cd "$FULLPATH/../view/en/"
23         OUTFILE="$FULLPATH/messages.po"
24         FINDSTARTDIR="../../"
25         # skip addon folder
26         FINDOPTS="-wholename */addon -prune -o"
27 fi
28
29 F9KVERSION=$(sed -n "s/.*'FRIENDICA_VERSION'.*'\([0-9.]*\)'.*/\1/p" ../../boot.php);
30
31 echo "Friendica version $F9KVERSION"
32
33 OPTS=
34
35 #if [ "" != "$1" ]
36 #then
37 #       OUTFILE="$(readlink -f ${FULLPATH}/$1)"
38 #       if [ -e "$OUTFILE" ]
39 #       then
40 #               echo "join extracted strings"
41 #               OPTS="-j"
42 #       fi
43 #fi
44
45 KEYWORDS="-k -kt -ktt:1,2"
46
47 echo "extract strings to $OUTFILE.."
48 rm "$OUTFILE"; touch "$OUTFILE"
49 for f in $(find "$FINDSTARTDIR" $FINDOPTS -name "*.php" -type f)
50 do
51         if [ ! -d "$f" ]
52         then
53                 xgettext $KEYWORDS $OPTS -j -o "$OUTFILE" --from-code=UTF-8 "$f"
54         fi
55 done
56
57 echo "setup base info.."
58 if [ $ADDONMODE ]
59 then 
60         sed -i "s/SOME DESCRIPTIVE TITLE./ADDON $ADDONNAME/g" "$OUTFILE"
61         sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER//g" "$OUTFILE"
62         sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.//g" "$OUTFILE"
63         sed -i "s/PACKAGE VERSION//g" "$OUTFILE"
64         sed -i "s/PACKAGE/Friendica $ADDONNAME addon/g" "$OUTFILE"
65         sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
66         sed -i "s/^\"Plural-Forms/#\"Plural-Forms/g" "$OUTFILE"
67 else
68         sed -i "s/SOME DESCRIPTIVE TITLE./FRIENDICA Distributed Social Network/g" "$OUTFILE"
69         sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2010, 2011, 2012, 2013 the Friendica Project/g" "$OUTFILE"
70         sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Mike Macgirvin, 2010/g" "$OUTFILE"
71         sed -i "s/PACKAGE VERSION/$F9KVERSION/g" "$OUTFILE"
72         sed -i "s/PACKAGE/Friendica/g" "$OUTFILE"
73         sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
74         sed -i "s/^\"Plural-Forms/#\"Plural-Forms/g" "$OUTFILE"
75 fi
76
77 echo "done."