xwp / wp-dev-lib

DEPRECATED. Common code used during development of WordPress plugins and themes
MIT License
279 stars 65 forks source link

Automatically (re-)generate POT files #46

Open westonruter opened 9 years ago

westonruter commented 9 years ago

See also https://github.com/wp-cli/wp-cli/issues/1042

JDGrimes commented 9 years ago

Here is a bash script I hacked together yesterday:

##
# Refreshes POMO translations.
##
wp-pot-update () {

    if [ -z $1 ]; then
        echo 'Usage: wp-pot-update <wordpoints-src>'
        return 0
    fi

    src=`cd "$1"; pwd`

    php ~/svn/wordpress/trunk/tools/i18n/makepot.php wp-plugin "$src" "$src/languages/wordpoints.pot"

    for f in $(find "$src/languages" -name '*.po' -type f); do
        msgmerge --update "$f" "$src/languages/wordpoints.pot"
        msgfmt -o "${f%po}mo" "$f"
    done
}

It uses the i18n tools packaged with WordPress trunk to generate the POT file, and then updates the po and mo files. I thought it might be worth sharing here. (Though, of course, it needs to be more generalized.)

frankiejarrett commented 9 years ago

:+1: for this feature! It will be so handy to do this on the pre-commit hook.

westonruter commented 8 years ago

I don't think this is relevant anymore with the new reality of translate.wordpress.org

valendesigns commented 8 years ago

I would do it with Grunt anyhow. This might be relevant for private repos that need transitions though.

frankiejarrett commented 8 years ago

It's very relevant for private plugins, as well as free plugins alike that already have PO files and elect not to crowdsource the translations.

westonruter commented 8 years ago

OK :smile: