From 4e53b7d178fe29d87d79b4353dceb93b906ff21a Mon Sep 17 00:00:00 2001 From: William MARTIN Date: Tue, 22 Feb 2011 11:32:59 +0100 Subject: [PATCH 1/4] Create a Makefile for common task - Generate tarball from GIT, using git archive - Updating POT file - Updating PO file --- .gitignore | 1 + Makefile | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 21998a7..ed1a860 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ www/media/upload src/IDF/gettexttemplates indefero-*.zip src/IDF/conf/path.php +.tx/config diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d89d527 --- /dev/null +++ b/Makefile @@ -0,0 +1,107 @@ +# ***** BEGIN LICENSE BLOCK ***** +# This file is part of InDefero, an open source project management application. +# Copyright (C) 2010 CĂ©ondo Ltd and contributors. +# +# InDefero is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# InDefero is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# ***** END LICENSE BLOCK ***** */ + +# Installation of external tools : transifex-client +# sudo apt-get install python-setuptools +# sudo easy_install -U transifex-client + +PLUF_PATH=$(shell php -r "require_once('src/IDF/conf/path.php'); echo PLUF_PATH;") + +all help: + @echo "Rules for generate tarball :" + @for b in `git branch | sed "s/^. //g"`; do \ + echo "\t"$$b"_tarball - Generate a zip archive of the "$$b" branch."; \ + done + @echo "\nRules for internationnalization :"; + @echo "\tpot-update - Update the POT file from HTML template and PHP source, then merge it with PO file" + @echo "\tpot-push - Send the POT file on transifex server" + @echo "\tpo-update - Merge POT file into PO file. POT is not regenerated." + @echo "\tpo-push - Send the all PO file on transifex server" + @echo "\tpo-pull - Get all PO file from transifex server" + +# +# Internationnalization rule, POT & PO file manipulation +# +.PHONY: pot-update po-update +pot-update: + # Backup pot file + cd src; cp -f IDF/locale/idf.pot IDF/locale/idf.pot.bak + # Extract string + @cd src; php $(PLUF_PATH)/extracttemplates.php IDF/conf/idf.php IDF/gettexttemplates + @cd src; for phpfile in `find . -iname "*.php"`; do \ + echo "Parsing file : "$$phpfile; \ + xgettext -o idf.pot -p ./IDF/locale/ --from-code=UTF-8 -j --keyword --keyword=__ --keyword=_n:1,2 -L PHP $$phpfile ; \ + done + # Remove tmp folder + rm -Rf src/IDF/gettexttemplates + # Update PO + @make po-update + +po-update: + @for pofile in `ls src/IDF/locale/*/idf.po`; do \ + echo "Updating file : "$$pofile; \ + msgmerge -v --width=10 -U $$pofile src/IDF/locale/idf.pot; \ + echo ; \ + done + +# +# Transifex +# +.PHONY: check-tx-config +check-tx-config: + @if [ ! -e .tx/config ]; then \ + mkdir -p .tx; \ + touch .tx/config; \ + echo "[main]" >> .tx/config; \ + echo "host = http://www.transifex.net" >> .tx/config; \ + echo "" >> .tx/config; \ + echo "[indefero.idfpot]" >> .tx/config; \ + echo "file_filter = src/IDF/locale//idf.po" >> .tx/config; \ + echo "source_file = src/IDF/locale/idf.pot" >> .tx/config; \ + echo "source_lang = en" >> .tx/config; \ + fi + @if [ ! -e $(HOME)/.transifexrc ]; then \ + touch $(HOME)/.transifexrc; \ + echo "[http://www.transifex.net]" >> $(HOME)/.transifexrc; \ + echo "username = " >> $(HOME)/.transifexrc; \ + echo "token = " >> $(HOME)/.transifexrc; \ + echo "password = " >> $(HOME)/.transifexrc; \ + echo "hostname = http://www.transifex.net" >> $(HOME)/.transifexrc; \ + echo "You must edit the file ~/.transifexrc to setup your transifex account (login & password) !"; \ + exit 1; \ + fi + +pot-push: check-tx-config + @tx push -s + +po-push: check-tx-config + @tx push -t + +po-pull: check-tx-config + @tx pull -a + +# +# Generic rule to build a tarball of indefero for a specified branch +# ex: make master_tarball +# make dev_tarball +# +%_tarball: + @git archive --format=zip --prefix="indefero/" $(@:_tarball=) > indefero-$(@:_tarball=)-`git log $(@:_tarball=) -n 1 --pretty=format:%H`.zip + From a28604ae4f3852b0b336758463a788f520d7c238 Mon Sep 17 00:00:00 2001 From: William MARTIN Date: Tue, 22 Feb 2011 11:43:01 +0100 Subject: [PATCH 2/4] Ignore backup file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ed1a860..2cb8e6c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*~ tmp src/IDF/conf/idf.php src/IDF/conf/idf.test.php From c2207452bdf3bbca2ad1d118aa52ceca5c506733 Mon Sep 17 00:00:00 2001 From: William MARTIN Date: Tue, 22 Feb 2011 14:26:09 +0100 Subject: [PATCH 3/4] Update the POT generation in Makefile Really delete the older POT file to avoid merge with old entry --- .gitignore | 1 + Makefile | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2cb8e6c..ddd52b8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ src/IDF/gettexttemplates indefero-*.zip src/IDF/conf/path.php .tx/config +src/IDF/locale/idf.pot.bak diff --git a/Makefile b/Makefile index d89d527..9794118 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,10 @@ all help: .PHONY: pot-update po-update pot-update: # Backup pot file - cd src; cp -f IDF/locale/idf.pot IDF/locale/idf.pot.bak + @if [ -e src/IDF/locale/idf.pot ]; then \ + mv -f src/IDF/locale/idf.pot src/IDF/locale/idf.pot.bak; \ + fi + touch src/IDF/locale/idf.pot; # Extract string @cd src; php $(PLUF_PATH)/extracttemplates.php IDF/conf/idf.php IDF/gettexttemplates @cd src; for phpfile in `find . -iname "*.php"`; do \ From f95ff57db9265abd662e5bd7a25868f8efcea76b Mon Sep 17 00:00:00 2001 From: William MARTIN Date: Tue, 22 Feb 2011 14:34:58 +0100 Subject: [PATCH 4/4] Remove --width option for msgmerge --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9794118..07636fe 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ pot-update: po-update: @for pofile in `ls src/IDF/locale/*/idf.po`; do \ echo "Updating file : "$$pofile; \ - msgmerge -v --width=10 -U $$pofile src/IDF/locale/idf.pot; \ + msgmerge -v -U $$pofile src/IDF/locale/idf.pot; \ echo ; \ done