Skip to content

Instantly share code, notes, and snippets.

@guelau
Created April 23, 2014 22:02
Show Gist options
  • Save guelau/11233994 to your computer and use it in GitHub Desktop.
Save guelau/11233994 to your computer and use it in GitHub Desktop.
This script get PHP gettext string (finds the "__" function) and merges them in .po files.
#!/bin/bash
XGETTEXT=/usr/bin/xgettext
XMESGMERG=/usr/bin/msgmerge
DOMAIN="messages.po"
TEMPLATE="messages.pot"
if [ ! -e "$1" ]; then
touch $1
fi
find . -type f -iname "*.php" -o -iname "*.phtml" | $XGETTEXT -p $1 -o $TEMPLATE -L php -j --keyword=__ -n --from-code=utf-8 -f -
find $1 -type f -iname $DOMAIN > ./messages.tmp
while read fichier
do
$XMESGMERG -o $fichier $fichier "$1/$TEMPLATE"
done < ./messages.tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment