Skip to content

Instantly share code, notes, and snippets.

@mattrude
Created September 19, 2010 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattrude/586627 to your computer and use it in GitHub Desktop.
Save mattrude/586627 to your computer and use it in GitHub Desktop.
Importing Translations from glotpress
#!/bin/bash
NAME=custom-css
GIT=custom-css.git
TRANSDIR=mdr-network/custom-css
POTNAME=safecss
#!/bin/bash
# Working on Milly Theme
if [ -e /tmp/translations/milly ]; then
cd /tmp/translations/milly
<<<<<<< HEAD
git reset --hard -q
echo "pulling"
git pull -q
echo "done pulling"
else
mkdir -p /tmp/translations
git clone git@git.mattrude.com:public/wp-theme-milly.git /tmp/translations/milly
cd /tmp/translations/milly
fi
xgettext --keyword=__ --keyword=_e --from-code=php --language=php *.php */*.php \
--package-version=1.0 --package-name=milly --output=language/milly.pot.tmp
cd /tmp/translations/milly/language/
cat milly.pot.tmp |grep -v "POT-Creation-Date:" > milly.pot.new
cat milly.pot |grep -v "POT-Creation-Date:" > milly.pot.old
diff=`diff milly.pot.new milly.pot.old`
if [ "$diff" = "" ]; then
rm -rf milly.pot.new milly.pot.old milly.pot.tmp
else
echo "Updating the milly.pot file."
rm -rf milly.pot milly.pot.new milly.pot.old
mv milly.pot.tmp milly.pot
php /var/www/translate.mattrude.com/scripts/import-originals.php -p milly -f /var/www/therudes.com/wp-content/themes/milly/language/milly.pot -o po
sleep 10
fi
=======
git reset --hard
git pull origin master
else
git clone git@git.mattrude.com:public/wp-theme-milly /tmp/translations/milly
cd /tmp/translations/milly
fi
cp language/milly.pot language/milly.pot.old
xgettext --keyword=__ --keyword=_e --from-code=php --language=php *.php */*.php --package-version=1.0 --package-name=milly --output=language/milly.pot.new
cat language/milly.pot.new |grep -v "POT-Creation-Date" > language/milly.pot.new.tmp
cat language/milly.pot |grep -v "POT-Creation-Date" > language/milly.pot.old.tmp
DIFF=`diff language/milly.pot.old.tmp language/milly.pot.new.tmp |wc -l`
if [ $DIFF != 0 ]; then
echo "Updating milly.pot"
pwd
rm -f language/milly.pot
mv language/milly.pot.new language/milly.pot
fi
rm -f language/milly.pot.old language/milly.pot.old.tmp language/milly.pot.new.tmp language/milly.pot.new
>>>>>>> 8922f6c51bcc938178069e13dc656e7be153aab7
cd /tmp/translations/milly/language/
for a in `echo 'ar cs da de es es_CL fr it ja ko nl pt pt_BR ru tr zh_CN zh_TW'`
do
<<<<<<< HEAD
rm -rf $a.*.bkp
mv $a.po $a.po.bkp
mv $a.mo $a.mo.bkp
b=`echo $a |sed --expression='s/_/-/' |tr "[A-Z]" "[a-z]"`
curl -s -o $a.po http://translate.mattrude.com/projects/milly/$b/default/export-translations
cat $a.po |grep -v "PO-Revision-Date:" > $a.po.new
cat $a.po.bkp |grep -v "PO-Revision-Date:" > $a.po.old
diff=`diff $a.po.new $a.po.old`
if [ "$diff" = "" ]; then
rm -rf $a.po $a.po.new $a.po.old
mv $a.po.bkp $a.po
mv $a.mo.bkp $a.mo
else
echo "Updating $a in the Milly Theme"
rm -rf $a.*.bkp $a.po.new $a.po.old
msgfmt -o $a.mo $a.po
fi
=======
#rm -rf $a.*
b=`echo $a |sed --expression='s/_/-/' |tr "[A-Z]" "[a-z]"`
curl -o $a.po.new http://translate.mattrude.com/projects/milly/$b/default/export-translations
cat $a.po.new |grep -v "PO-Revision-Date:" > $a.po.new.tmp
cat $a.po |grep -v "PO-Revision-Date:" > $a.po.old.tmp
DIFF=`diff $a.po.old.tmp $a.po.new.tmp |wc -l`
if [ $DIFF != 0 ]; then
echo "updating $a"
rm -f $a.po
mv $a.po.new.tmp $a.po
rm -f $a.mo
msgfmt -o $a.mo $a.po
fi
rm -f $a.po.new $a.po.new.tmp $a.po.old.tmp
>>>>>>> 8922f6c51bcc938178069e13dc656e7be153aab7
sleep 1
done
<<<<<<< HEAD
cd /tmp/translations/milly/language/
status=`git status -s`
if [ "$status" != "" ]; then
echo "Updating git repository with changes for Milly"
git add *
git commit * -m "Updating Translation Strings" -q && git push -q
fi
=======
exit 0
>>>>>>> 8922f6c51bcc938178069e13dc656e7be153aab7
exit 0
# Working on mdr nework
cd /var/www/therudes.com/wp-content/mu-plugins/
xgettext --keyword=__ --keyword=_e --from-code=php --language=php *.php */*.php */*/*.php \
--package-version=1.0 --package-name=mdr-network --output=languages/mdr-network.pot.tmp
cd /var/www/therudes.com/wp-content/mu-plugins/languages/
cat mdr-network.pot.tmp |grep -v "POT-Creation-Date:" > mdr-network.pot.new
cat mdr-network.pot |grep -v "POT-Creation-Date:" > mdr-network.pot.old
diff=`diff mdr-network.pot.new mdr-network.pot.old`
if [ "$diff" = "" ]; then
rm -rf mdr-network.pot.new
rm -rf mdr-network.pot.old
rm -rf mdr-network.pot.tmp
else
echo "Updating the mdr-network.pot file."
rm -rf mdr-network.pot
rm -rf mdr-network.pot.new
rm -rf mdr-network.pot.old
mv mdr-network.pot.tmp mdr-network.pot
php /var/www/translate.mattrude.com/scripts/import-originals.php -p network-plugins -f /var/www/therudes.com/wp-content/mu-plugins/languages/mdr-network.pot -o po
sleep 10
fi
cd /var/www/therudes.com/wp-content/mu-plugins/languages/
for a in `echo 'ar cs da de es es_CL fr it ja ko nl pt pt_BR ru tr zh_CN zh_TW'`
do
rm -rf $a.*.bkp
mv $a.po $a.po.bkp
mv $a.mo $a.mo.bkp
b=`echo $a |sed --expression='s/_/-/' |tr "[A-Z]" "[a-z]"`
curl -s -o $a.po http://translate.mattrude.com/projects/network-plugins/$b/default/export-translations
cat $a.po |grep -v "PO-Revision-Date:" > $a.po.new
cat $a.po.bkp |grep -v "PO-Revision-Date:" > $a.po.old
diff=`diff $a.po.new $a.po.old`
if [ "$diff" = "" ]; then
rm -rf $a.po $a.po.new $a.po.old
mv $a.po.bkp $a.po
mv $a.mo.bkp $a.mo
else
echo "Updating $a in mdr-network"
rm -rf $a.*.bkp $a.po.new $a.po.old
msgfmt -o $a.mo $a.po
fi
sleep 1
done
cd /var/www/therudes.com/wp-content/mu-plugins/languages/
status=`git status -s`
if [ "$status" != "" ]; then
echo "Updating git repository with changes for MDR Netork Plugins"
git add *
git commit * -m "Updating Translation Strings" -q && git push -q
fi
<<<<<<< HEAD
# Working on Custom CSS (safecss)
cd /var/www/therudes.com/wp-content/plugins/safecss
xgettext --keyword=__ --keyword=_e --from-code=php --language=php *.php */*.php \
--package-version=1.0 --package-name=safecss --output=languages/safecss.pot.tmp
cd /var/www/therudes.com/wp-content/plugins/safecss/languages/
cat safecss.pot.tmp |grep -v "POT-Creation-Date:" > safecss.pot.new
cat safecss.pot |grep -v "POT-Creation-Date:" > safecss.pot.old
diff=`diff safecss.pot.new safecss.pot.old`
if [ "$diff" = "" ]; then
rm -rf safecss.pot.new
rm -rf safecss.pot.old
rm -rf safecss.pot.tmp
else
echo "Updating the safecss.pot file."
rm -rf safecss.pot
rm -rf safecss.pot.new
rm -rf safecss.pot.old
mv safecss.pot.tmp /var/www/therudes.com/wp-content/plugins/safecss/languages/safecss.pot
php /var/www/translate.mattrude.com/scripts/import-originals.php -p network-plugins/custom-css -f /var/www/therudes.com/wp-content/plugins/safecss/languages/safecss.pot -o po
sleep 10
fi
cd /var/www/therudes.com/wp-content/plugins/safecss/languages/
for a in `echo 'ar cs da de es es_CL fr it ja ko nl pt pt_BR ru tr zh_CN zh_TW'`
do
rm -rf $a.*.bkp
mv $a.po $a.po.bkp
mv $a.mo $a.mo.bkp
b=`echo $a |sed --expression='s/_/-/' |tr "[A-Z]" "[a-z]"`
curl -s -o $a.po http://translate.mattrude.com/projects/network-plugins/custom-css/$b/default/export-translations
cat $a.po |grep -v "PO-Revision-Date:" > $a.po.new
cat $a.po.bkp |grep -v "PO-Revision-Date:" > $a.po.old
diff=`diff $a.po.new $a.po.old`
if [ "$diff" = "" ]; then
rm -rf $a.po $a.po.new $a.po.old
mv $a.po.bkp $a.po
mv $a.mo.bkp $a.mo
else
echo "Updating $a in safecss"
rm -rf $a.*.bkp $a.po.new $a.po.old
msgfmt -o $a.mo $a.po
fi
sleep 1
done
cd /var/www/therudes.com/wp-content/plugins/safecss/languages/
status=`git status -s`
if [ "$status" != "" ]; then
echo "Updating git repository with changes for Custom CSS"
git add *
git commit * -m "Updating Translation Strings" -q && git push -q
fi
cd /var/www/therudes.com/wp-content/languages/
for a in `echo 'ar cs da de es es_CL fr it ja ko nl pt pt_BR ru tr zh_CN'`
do
rm -rf $a.*
b=`echo $a |sed --expression='s/_/-/' |tr "[A-Z]" "[a-z]"`
curl -s -o $a.po http://translate.wordpress.org/projects/wp/3.0.x/$b/default/export-translations
curl -s -o ms-$a.po http://translate.wordpress.org/projects/wp/3.0.x/ms/$b/default/export-translations
msgfmt -o $a.mo $a.po
msgfmt -o ms-$a.mo ms-$a.po
sleep 1
done
cd /var/www/therudes.com/wp-content/plugins/safecss/
=======
# Working on Custom CSS/safecss
if [ -e /tmp/translations/safecss ]; then
cd /tmp/translations/safecss
git reset --hard
git pull origin master
else
mkdir -p /tmp/translations/safecss
cd /tmp/translations/safecss
git clone git@git.mattrude.com:public/custom-css.git
fi
>>>>>>> 8922f6c51bcc938178069e13dc656e7be153aab7
rm -rf safecss.pot
xgettext --keyword=__ --keyword=_e --from-code=php --language=php safecss.php \
--package-version=1.0 --package-name=safecss --output=safecss.pot
#cd /var/www/therudes.com/wp-content/plugins/wordpress-mu-domain-mapping/
#rm -rf domain_mapping.pot
#xgettext --keyword=__ --keyword=_e --from-code=php --language=php domain_mapping.php \
#--package-version=1.0 --package-name=domain_mapping --output=domain_mapping.pot
#cd /var/www/therudes.com/wp-content/languages/
#for a in `echo 'ar cs da de es es_CL fr it ja ko nl pt pt_BR ru tr zh_CN zh_TW'`
#do
# rm -rf $a.*
# b=`echo $a |sed --expression='s/_/-/' |tr "[A-Z]" "[a-z]"`
# curl -o $a.po http://translate.wordpress.org/projects/wp/3.0.x/$b/default/export-translations
# curl -o ms-$a.po http://translate.wordpress.org/projects/wp/3.0.x/ms/$b/default/export-translations
# msgfmt -o $a.mo $a.po
# msgfmt -o ms-$a.mo ms-$a.po
# sleep 1
#done
#!/bin/bash
if [ -e $1 ]; then
source $1
CONFIGSTATUS="Using config file found at $1"
else
echo "No Config file found"
exit 1
fi
DIR=/tmp/translations/$NAME
if [ ! $TRANSDIR ]; then
TRANSDIR=$NAME
fi
if [ ! $POTNAME ]; then
POTNAME=$NAME
fi
# Working on Milly Theme
if [ -e /tmp/translations/$NAME ]; then
cd /tmp/translations/$NAME
git reset --hard -q
git pull -q
else
mkdir -p /tmp/translations
git clone git@git.mattrude.com:public/$GIT /tmp/translations/$NAME
cd $DIR
fi
if [ -e /tmp/translations/$NAME/language ]; then
LANGDIR=/tmp/translations/$NAME/language
else
if [ -e /tmp/translations/$NAME/languages ]; then
LANGDIR=/tmp/translations/$NAME/languages
else
exit 1
fi
fi
xgettext --keyword=__ --keyword=_e --from-code=php --language=php *.php */*.php \
--package-version=1.0 --package-name=$NAME --output=$LANGDIR/$POTNAME.pot.tmp
cd $LANGDIR
cat $POTNAME.pot.tmp |grep -v "POT-Creation-Date:" > $POTNAME.pot.new
cat $POTNAME.pot |grep -v "POT-Creation-Date:" > $POTNAME.pot.old
diff=`diff $POTNAME.pot.new $POTNAME.pot.old`
if [ "$diff" = "" ]; then
rm -rf $POTNAME.pot.new $POTNAME.pot.old $POTNAME.pot.tmp
else
echo "Updating the $POTNAME.pot file."
rm -rf $POTNAME.pot $POTNAME.pot.new $POTNAME.pot.old
mv $POTNAME.pot.tmp $POTNAME.pot
php /var/www/translate.mattrude.com/scripts/import-originals.php -p $TRANSDIR -f $LANGDIR/$POTNAME.pot -o po
sleep 10
fi
cd $LANGDIR
for a in `echo 'ar cs da de es es_CL fr it ja ko nl pt pt_BR ru tr zh_CN zh_TW'`
do
rm -rf $a.*.bkp
mv $a.po $a.po.bkp
mv $a.mo $a.mo.bkp
b=`echo $a |sed --expression='s/_/-/' |tr "[A-Z]" "[a-z]"`
curl -s -o $a.po http://translate.mattrude.com/projects/$TRANSDIR/$b/default/export-translations
cat $a.po |grep -v "PO-Revision-Date:" > $a.po.new
cat $a.po.bkp |grep -v "PO-Revision-Date:" > $a.po.old
diff=`diff $a.po.new $a.po.old`
if [ "$diff" = "" ]; then
rm -rf $a.po $a.po.new $a.po.old
mv $a.po.bkp $a.po
mv $a.mo.bkp $a.mo
else
echo "Updating $a in $NAME"
rm -rf $a.*.bkp $a.po.new $a.po.old
msgfmt -o $a.mo $a.po
fi
sleep 1
done
cd $LANGDIR
status=`git status -s`
if [ "$status" != "" ]; then
echo "Updating git repository with changes for $NAME"
git add *
git commit * -m "Updating Translation Strings" -q && git push -q
fi
#!/bin/bash
cd /home/matt/bin/gists/586627
for a in `ls *.conf`; do ./import.sh $a; done
#!/bin/bash
NAME=mdr-network
GIT=mdr-network.git
#!/bin/bash
NAME=milly
GIT=wp-theme-milly.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment