2 FULLPATH=$(dirname $(readlink -f "$0"))
4 if [ "$1" == "--help" -o "$1" == "-h" ]
6 echo "$(basename $(readlink -f "$0")) [options]"
8 echo "-a | --addon <name> extract strings from addon 'name'"
9 echo "-s | --single single addon mode: extract string from current folder"
15 if [ "$1" == "--addon" -o "$1" == "-a" ]
18 if [ -z $2 ]; then echo -e "ERROR: missing addon name\n\nrun_xgettext.sh -a <addonname>"; exit 1; fi
20 if [ ! -d "$FULLPATH/../addon/$ADDONNAME" ]; then echo "ERROR: addon '$ADDONNAME' not found"; exit 2; fi
23 if [ "$1" == "--single" -o "$1" == "-s" ]
31 cd "$FULLPATH/../addon/$ADDONNAME"
32 mkdir -p "$FULLPATH/../addon/$ADDONNAME/lang/C"
33 OUTFILE="$FULLPATH/../addon/$ADDONNAME/lang/C/messages.po"
39 ADDONNAME=$(basename $FULLPATH)
40 mkdir -p "$FULLPATH/lang/C"
41 OUTFILE="$FULLPATH/lang/C/messages.po"
44 echo "Extract strings for single addon '$ADDONNAME'"
48 OUTFILE="$FULLPATH/../util/messages.po"
51 FINDOPTS="( -wholename */addon -or -wholename */addons -or -wholename */addons-extra -or -wholename */smarty3 ) -prune -o"
53 F9KVERSION=$(sed -n "s/.*'FRIENDICA_VERSION'.*'\([0-9.]*\)'.*/\1/p" ./boot.php);
54 echo "Friendica version $F9KVERSION"
59 KEYWORDS="-k -kt -ktt:1,2"
61 echo "extract strings to $OUTFILE.."
62 rm "$OUTFILE"; touch "$OUTFILE"
63 for f in $(find "$FINDSTARTDIR" $FINDOPTS -name "*.php" -type f)
67 xgettext $KEYWORDS -j -o "$OUTFILE" --from-code=UTF-8 "$f"
68 sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
72 echo "setup base info.."
75 sed -i "s/SOME DESCRIPTIVE TITLE./ADDON $ADDONNAME/g" "$OUTFILE"
76 sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER//g" "$OUTFILE"
77 sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.//g" "$OUTFILE"
78 sed -i "s/PACKAGE VERSION//g" "$OUTFILE"
79 sed -i "s/PACKAGE/Friendica $ADDONNAME addon/g" "$OUTFILE"
80 sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
81 sed -i "s/^\"Plural-Forms.*$//g" "$OUTFILE"
84 sed -i "s/SOME DESCRIPTIVE TITLE./FRIENDICA Distributed Social Network/g" "$OUTFILE"
85 sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2010, 2011, 2012, 2013 the Friendica Project/g" "$OUTFILE"
86 sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Mike Macgirvin, 2010/g" "$OUTFILE"
87 sed -i "s/PACKAGE VERSION/$F9KVERSION/g" "$OUTFILE"
88 sed -i "s/PACKAGE/Friendica/g" "$OUTFILE"
89 sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
90 sed -i "s/^\"Plural-Forms.*$//g" "$OUTFILE"
94 if [ "" != "$1" -a "$MODE" == "default" ]
96 UPDATEFILE="$(readlink -f ${FULLPATH}/$1)"
97 echo "merging new strings to $UPDATEFILE.."
98 msgmerge -U $OUTFILE $UPDATEFILE