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"
35 FINDOPTS="-path ./vendor -prune -or"
39 ADDONNAME=$(basename $FULLPATH)
40 mkdir -p "$FULLPATH/lang/C"
41 OUTFILE="$FULLPATH/lang/C/messages.po"
43 FINDOPTS="-path ./vendor -prune -or"
44 echo "Extract strings for single addon '$ADDONNAME'"
48 OUTFILE="$FULLPATH/../view/lang/C/messages.po"
51 FINDOPTS="( -path ./addon -or -path ./addons -or -path ./addons-extra -or -path ./tests -or -path ./view/lang -or -path ./view/smarty3 -or -path ./vendor ) -prune -or"
53 F9KVERSION=$(cat ./VERSION);
54 echo "Friendica version $F9KVERSION"
59 KEYWORDS="-k -kt -ktt:1,2"
61 echo "Extract strings to $OUTFILE.."
62 rm "$OUTFILE"; touch "$OUTFILE"
64 find_result=$(find "$FINDSTARTDIR" $FINDOPTS -name "*.php" -type f)
66 total_files=$(wc -l <<< "${find_result}")
68 for file in $find_result
72 echo -ne "Reading file $count/$total_files..."
74 # On Windows, find still outputs the name of pruned folders
77 xgettext $KEYWORDS -j -o "$OUTFILE" --from-code=UTF-8 "$file" || exit 1
78 sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
83 echo "Interpolate metadata.."
85 sed -i "s/^\"Plural-Forms.*$//g" "$OUTFILE"
89 sed -i "s/SOME DESCRIPTIVE TITLE./ADDON $ADDONNAME/g" "$OUTFILE"
90 sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER//g" "$OUTFILE"
91 sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.//g" "$OUTFILE"
92 sed -i "s/PACKAGE VERSION//g" "$OUTFILE"
93 sed -i "s/PACKAGE/Friendica $ADDONNAME addon/g" "$OUTFILE"
96 sed -i "s/SOME DESCRIPTIVE TITLE./FRIENDICA Distributed Social Network/g" "$OUTFILE"
97 sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2010-$(date +%Y) the Friendica Project/g" "$OUTFILE"
98 sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Mike Macgirvin, 2010/g" "$OUTFILE"
99 sed -i "s/PACKAGE VERSION/$F9KVERSION/g" "$OUTFILE"
100 sed -i "s/PACKAGE/Friendica/g" "$OUTFILE"
104 if [ "" != "$1" -a "$MODE" == "default" ]
106 UPDATEFILE="$(readlink -f ${FULLPATH}/$1)"
107 echo "Merging new strings to $UPDATEFILE.."
108 msgmerge -U $OUTFILE $UPDATEFILE