wp-dev-lib icon indicating copy to clipboard operation
wp-dev-lib copied to clipboard

Automatically (re-)generate POT files

Open westonruter opened this issue 11 years ago • 7 comments

westonruter avatar Oct 22 '14 19:10 westonruter

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

westonruter avatar Oct 22 '14 19:10 westonruter

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.)

JDGrimes avatar Oct 25 '14 15:10 JDGrimes

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

frankiejarrett avatar Jan 07 '15 04:01 frankiejarrett

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

westonruter avatar Feb 26 '16 23:02 westonruter

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

valendesigns avatar Feb 26 '16 23:02 valendesigns

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.

frankiejarrett avatar Feb 27 '16 00:02 frankiejarrett

OK :smile:

westonruter avatar Feb 27 '16 01:02 westonruter