Created
July 1, 2014 17:03
-
-
Save raspi/f3bb3ea92d6e4a108f1f to your computer and use it in GitHub Desktop.
Shell script for updating Gettext .po files in a PHP project. Create new languages simply by copying base.pot to <language code>.po. For example: cp base.pot fi.po. Then just edit fi.po with poedit or some other editor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# generate file list | |
echo -e "" > files.txt | |
find ../application -type f \( -iname "*.php" -or -iname "*.phtml" \) -exec readlink -f "{}" \; > files.txt | |
# scan files | |
xgettext --force-po --add-comments --from-code=UTF-8 --language=php --package-name=app --package-version=1.0 [email protected] -o base.pot -f files.txt | |
# base pot -> <lang>.po update | |
find . -type f -iname "*.po" -exec bash -c 'msgmerge --update "{}" base.pot' \; | |
# compile .po to .mo | |
find . -type f -iname "*.po" -exec bash -c 'msgfmt "{}" -o "$(basename "{}" .po).mo"' \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment