| 1 |
#! /bin/sh |
|---|
| 2 |
# Copyright (c) 2008, 2010 Mikael Carlsson |
|---|
| 3 |
# This program is free software; you can redistribute it and/or |
|---|
| 4 |
# modify it under the terms of the GNU General Public License |
|---|
| 5 |
# as published by the Free Software Foundation; either version 2 |
|---|
| 6 |
# of the License, or (at your option) any later version. |
|---|
| 7 |
# |
|---|
| 8 |
# This program is distributed in the hope that it will be useful, |
|---|
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 |
# GNU General Public License for more details. |
|---|
| 12 |
# |
|---|
| 13 |
# The purpose of this script is to extract all text strings from all FreePBX code that can |
|---|
| 14 |
# be translated and create template files under each modules/<module>/i18n directory. |
|---|
| 15 |
# This script is intended to run in the checked out svn modules directory. |
|---|
| 16 |
# |
|---|
| 17 |
|
|---|
| 18 |
echo "Creating new POT template files for modules" |
|---|
| 19 |
echo "Checking if module $1 has an i18n directory" |
|---|
| 20 |
# spit out the module.xml in a <modulename>.i18.php so that we can grab it with the find |
|---|
| 21 |
if [ -d $1/i18n ]; then |
|---|
| 22 |
echo "Found directory $1/i18n, creating temp file" |
|---|
| 23 |
# This is needed for localization to actually pickup the enclosed text strings |
|---|
| 24 |
# This could probably be done better, but I lack the time for doing that so here it is |
|---|
| 25 |
echo -e "<?php \nif (false) {" > $1/$1.i18n.php |
|---|
| 26 |
/var/lib/asterisk/bin/module_admin i18n $1 >> $1/$1.i18n.php |
|---|
| 27 |
# This is needed for localization to actually pickup the enclosed text strings |
|---|
| 28 |
# This could probably be done better, but I lack the time for doing that so here it is |
|---|
| 29 |
echo -e "}\n?>\n" >> $1/$1.i18n.php |
|---|
| 30 |
echo "Creating $1.pot file, extracting text strings" |
|---|
| 31 |
# Save the file as a temp file |
|---|
| 32 |
find $1/*.php | xargs xgettext --no-location -L PHP -o $1/i18n/$1.tmp --keyword=_ - |
|---|
| 33 |
# Now add the copyright and the license info to the.pot file |
|---|
| 34 |
# Again, could be done better, but I lack the time and really need this out now |
|---|
| 35 |
echo "# This file is part of FreePBX." > $1/i18n/$1.pot |
|---|
| 36 |
echo "#" >> $1/i18n/$1.pot |
|---|
| 37 |
echo "# FreePBX is free software: you can redistribute it and/or modify" >> $1/i18n/$1.pot |
|---|
| 38 |
echo "# it under the terms of the GNU General Public License as published by" >> $1/i18n/$1.pot |
|---|
| 39 |
echo "# the Free Software Foundation, either version 2 of the License, or" >> $1/i18n/$1.pot |
|---|
| 40 |
echo "# (at your option) any later version." >> $1/i18n/$1.pot |
|---|
| 41 |
echo "#" >> $1/i18n/$1.pot |
|---|
| 42 |
echo "# FreePBX is distributed in the hope that it will be useful," >> $1/i18n/$1.pot |
|---|
| 43 |
echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of" >> $1/i18n/$1.pot |
|---|
| 44 |
echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" >> $1/i18n/$1.pot |
|---|
| 45 |
echo "# GNU General Public License for more details." >> $1/i18n/$1.pot |
|---|
| 46 |
echo "#" >> $1/i18n/$1.pot |
|---|
| 47 |
echo "# You should have received a copy of the GNU General Public License" >> $1/i18n/$1.pot |
|---|
| 48 |
echo "# along with FreePBX. If not, see <http://www.gnu.org/licenses/>." >> $1/i18n/$1.pot |
|---|
| 49 |
echo "#" >> $1/i18n/$1.pot |
|---|
| 50 |
echo "# FreePBX language template for $1" >> $1/i18n/$1.pot |
|---|
| 51 |
echo "# Copyright (C) 2008, 2009, 2010 Bandwith.com" >> $1/i18n/$1.pot |
|---|
| 52 |
echo "#" >> $1/i18n/$1.pot |
|---|
| 53 |
# Remove the first six lines of the .tmp file and put it in the -pot file |
|---|
| 54 |
/bin/sed '1,6d' $1/i18n/$1.tmp >> $1/i18n/$1.pot |
|---|
| 55 |
echo "Removing temp files" |
|---|
| 56 |
rm $1/$1.i18n.php |
|---|
| 57 |
rm $1/i18n/$1.tmp |
|---|
| 58 |
fi |
|---|
| 59 |
echo "Done, now don't forget to commit your work!" |
|---|