tools

更新本機測試環境的 WordPress 語系檔

如題。最近正在做 WordPress Development (future 3.4) 的翻譯,工具是 translate.wordpress.org 網站,為了可以隨時更新本機測試環境來做對照寫了一個簡單的腳本。

本機環境簡述:

  • Windows XP
  • Cygwin + gettext + gettext-devel

修改 WORDPRESS 的路徑後,存起來,放在 Cygwin 下去跑就會更新到最新的 zh_TW 語系檔案。

#!/bin/bash
 
#The path your wordpress installed
WORDPRESS=/cygdrive/c/xampplite/wordpress/
SITE=http://translate.wordpress.org/projects
PROJECT=/wp/dev
 
echo "Getting zh_TW.po from translate.wordpress.org"
curl -s $SITE$PROJECT/zh-tw/default/export-translations > zh_TW.po 
 
echo "Getting admin-zh_TW.po from translate.wordpress.org"
curl -s $SITE$PROJECT/admin/zh-tw/default/export-translations > admin-zh_TW.po
 
echo "Getting admin-network-zh_TW.po from translate.wordpress.org"
curl -s $SITE$PROJECT/admin/network/zh-tw/default/export-translations > admin-network-zh_TW.po
 
echo "Getting continents-cities-zh_TW.po from translate.wordpress.org"
curl -s $SITE$PROJECT/cc/zh-tw/default/export-translations > continents-cities-zh_TW.po
 
echo "Getting twentyten zh_TW.po from translate.wordpress.org"
curl -s $SITE$PROJECT/twentyten/zh-tw/default/export-translations > twentyten-zh_TW.po
 
echo "Getting twentyeleven zh_TW.po from translate.wordpress.org"
curl -s $SITE$PROJECT/twentyeleven/zh-tw/default/export-translations > twentyeleven-zh_TW.po
 
echo "Getting twentytwelve zh_TW.po from translate.wordpress.org"
curl -s $SITE$PROJECT/twentytwelve/zh-tw/default/export-translations > twentytwelve-zh_TW.po
 
echo "Generate zh_TW.mo"
msgfmt -o zh_TW.mo zh_TW.po 
 
echo "Generate admin-zh_TW.mo"
msgfmt -o admin-zh_TW.mo admin-zh_TW.po
 
echo "Generate admin-network-zh_TW.mo"
msgfmt -o admin-network-zh_TW.mo admin-network-zh_TW.po 
 
echo "Generate continents-cities-zh_TW.mo"
msgfmt -o continents-cities-zh_TW.mo continents-cities-zh_TW.po 
 
echo "Generate twentyten zh_TW.mo"
msgfmt -o twentyten-zh_TW.mo twentyten-zh_TW.po 
 
echo "Generate twentyeleven zh_TW.mo"
msgfmt -o twentyeleven-zh_TW.mo twentyeleven-zh_TW.po 
 
echo "Generate twentytwelve zh_TW.mo"
msgfmt -o twentytwelve-zh_TW.mo twentytwelve-zh_TW.po 
 
echo "Copy *.mo to local WordPress"
cp -f zh_TW.mo $WORDPRESS/wp-content/languages
cp -f admin-zh_TW.mo $WORDPRESS/wp-content/languages
cp -f admin-network-zh_TW.mo $WORDPRESS/wp-content/languages
cp -f continents-cities-zh_TW.mo $WORDPRESS/wp-content/languages
 
cp -f twentyten-zh_TW.mo $WORDPRESS/wp-content/themes/twentyten/languages/zh_TW.mo
cp -f twentyeleven-zh_TW.mo $WORDPRESS/wp-content/themes/twentyeleven/languages/zh_TW.mo
 
echo "Copy *.po to local WordPress"
cp -f zh_TW.po $WORDPRESS/wp-content/languages
cp -f admin-zh_TW.po $WORDPRESS/wp-content/languages
cp -f admin-network-zh_TW.po $WORDPRESS/wp-content/languages
cp -f continents-cities-zh_TW.po $WORDPRESS/wp-content/languages
 
cp -f twentyten-zh_TW.po $WORDPRESS/wp-content/themes/twentyten/languages/zh_TW.po
cp -f twentyeleven-zh_TW.po $WORDPRESS/wp-content/themes/twentyeleven/languages/zh_TW.po
 
echo "Done!"
conditions