| 1 |
#! /bin/sh |
|---|
| 2 |
# Copyright (c) 2008, 2011 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 |
# |
|---|
| 14 |
# The purpose of this script is to extract all text strings from all FreePBX code that can |
|---|
| 15 |
# be translated and create template files under each modules/<module>/i18n directory. |
|---|
| 16 |
# For this script to work you need to so svn co for for branch and for modules and |
|---|
| 17 |
# install this in the same tree so that the script can do all extraction at once. |
|---|
| 18 |
# |
|---|
| 19 |
|
|---|
| 20 |
echo "Creating new POT template files for modules" |
|---|
| 21 |
# go down to modules directory |
|---|
| 22 |
cd amp_conf/htdocs/admin/modules |
|---|
| 23 |
for modules in $(ls -d */); |
|---|
| 24 |
do |
|---|
| 25 |
echo "Checking if module ${modules%%/} has an i18n directory" |
|---|
| 26 |
# spit out the module.xml in a <modulename>.i18.php so that we can grab it with the find |
|---|
| 27 |
# all modules from svn MUST be installed as module_admin reads from |
|---|
| 28 |
# the installed modules NOT from the directory itself |
|---|
| 29 |
if [ -d ${modules}i18n ]; then |
|---|
| 30 |
echo "Found directory ${modules}i18n, creating temp file" |
|---|
| 31 |
# This is needed for localization to actually pickup the enclosed text strings |
|---|
| 32 |
# This could probably be done better, but I lack the time for doing that so here it is |
|---|
| 33 |
echo -e "<?php \nif (false) {" > $modules${modules%%/}.i18n.php |
|---|
| 34 |
/var/lib/asterisk/bin/module_admin i18n ${modules%%/} >> $modules${modules%%/}.i18n.php |
|---|
| 35 |
# This is needed for localization to actually pickup the enclosed text strings |
|---|
| 36 |
# This could probably be done better, but I lack the time for doing that so here it is |
|---|
| 37 |
echo -e "}\n?>\n" >> $modules${modules%%/}.i18n.php |
|---|
| 38 |
echo "Creating ${modules%%/}.pot file, extracting text strings" |
|---|
| 39 |
# Save the file as a temp file |
|---|
| 40 |
find ${modules%%/}/*.php | xargs xgettext --no-location -L PHP -o ${modules%%/}/i18n/${modules%%/}.tmp --keyword=_ - |
|---|
| 41 |
# Now add the copyright and the license info to the.pot file |
|---|
| 42 |
# Again, could be done better, but I lack the time and really need this out now |
|---|
| 43 |
echo "# This file is part of FreePBX." > ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 44 |
echo "#" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 45 |
echo "# FreePBX is free software: you can redistribute it and/or modify" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 46 |
echo "# it under the terms of the GNU General Public License as published by" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 47 |
echo "# the Free Software Foundation, either version 2 of the License, or" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 48 |
echo "# (at your option) any later version." >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 49 |
echo "#" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 50 |
echo "# FreePBX is distributed in the hope that it will be useful," >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 51 |
echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 52 |
echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 53 |
echo "# GNU General Public License for more details." >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 54 |
echo "#" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 55 |
echo "# You should have received a copy of the GNU General Public License" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 56 |
echo "# along with FreePBX. If not, see <http://www.gnu.org/licenses/>." >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 57 |
echo "#" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 58 |
echo "# FreePBX language template for ${modules%%/}" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 59 |
echo "# Copyright (C) 2008, 2009, 2010, 2011 Bandwith.com" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 60 |
echo "#" >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 61 |
# Remove the first six lines of the .tmp file and put it in the -pot file |
|---|
| 62 |
/bin/sed '1,6d' ${modules%%/}/i18n/${modules%%/}.tmp >> ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 63 |
# Now set Project to FreePBX and utf-8 as charset |
|---|
| 64 |
/bin/sed -i 's/PACKAGE VERSION/FreePBX/g' ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 65 |
/bin/sed -i 's/charset=CHARSET/charset=utf-8/g' ${modules%%/}/i18n/${modules%%/}.pot |
|---|
| 66 |
echo "Removing temp files" |
|---|
| 67 |
rm $modules${modules%%/}.i18n.php |
|---|
| 68 |
rm ${modules%%/}/i18n/${modules%%/}.tmp |
|---|
| 69 |
fi |
|---|
| 70 |
done |
|---|
| 71 |
# Go back two directory levels |
|---|
| 72 |
cd ../.. |
|---|
| 73 |
echo "Creating new POT template files for core" |
|---|
| 74 |
# spit out the module.xml for core and framework to amp.i18.php so that we can grab it with the find |
|---|
| 75 |
echo -e "<?php \nif (false) {" >> admin/modules/core/core.i18n.php |
|---|
| 76 |
/var/lib/asterisk/bin/module_admin i18n core >> admin/modules/core/core.i18n.php |
|---|
| 77 |
/var/lib/asterisk/bin/module_admin i18n framework >> admin/modules/core/core.i18n.php |
|---|
| 78 |
echo -e "}\n?>\n" >> admin/modules/core/core.i18n.php |
|---|
| 79 |
find admin/*.php admin/cdr/*.php admin/common/*.php admin/libraries/*.php admin/views/*.php admin/modules/core/*.php -maxdepth 0 | xargs xgettext --no-location -L PHP -o admin/i18n/amp.tmp --keyword=_ - |
|---|
| 80 |
echo "# This file is part of FreePBX." > admin/i18n/amp.pot |
|---|
| 81 |
echo "#" >> admin/i18n/amp.pot |
|---|
| 82 |
echo "# FreePBX is free software: you can redistribute it and/or modify" >> admin/i18n/amp.pot |
|---|
| 83 |
echo "# it under the terms of the GNU General Public License as published by" >> admin/i18n/amp.pot |
|---|
| 84 |
echo "# the Free Software Foundation, either version 2 of the License, or" >> admin/i18n/amp.pot |
|---|
| 85 |
echo "# (at your option) any later version." >> admin/i18n/amp.pot |
|---|
| 86 |
echo "#" >> admin/i18n/amp.pot |
|---|
| 87 |
echo "# FreePBX is distributed in the hope that it will be useful," >> admin/i18n/amp.pot |
|---|
| 88 |
echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of" >> admin/i18n/amp.pot |
|---|
| 89 |
echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" >> admin/i18n/amp.pot |
|---|
| 90 |
echo "# GNU General Public License for more details." >> admin/i18n/amp.pot |
|---|
| 91 |
echo "#" >> admin/i18n/amp.pot |
|---|
| 92 |
echo "# You should have received a copy of the GNU General Public License" >> admin/i18n/amp.pot |
|---|
| 93 |
echo "# along with FreePBX. If not, see <http://www.gnu.org/licenses/>." >> admin/i18n/amp.pot |
|---|
| 94 |
echo "#" >> admin/i18n/amp.pot |
|---|
| 95 |
echo "# FreePBX language template for amp" >> admin/i18n/amp.pot |
|---|
| 96 |
echo "# Copyright (C) 2008, 2009, 2010, 2011 Bandwith.com" >> admin/i18n/amp.pot |
|---|
| 97 |
echo "#" >> admin/i18n/amp.pot |
|---|
| 98 |
# remove the <modulename>.i18.php |
|---|
| 99 |
rm admin/modules/core/core.i18n.php |
|---|
| 100 |
# Remove the first six lines of the .tmp file and put it in the -pot file |
|---|
| 101 |
/bin/sed '1,6d' admin/i18n/amp.tmp >> admin/i18n/amp.pot |
|---|
| 102 |
# Now set Project to FreePBX and utf-8 as charset |
|---|
| 103 |
/bin/sed -i 's/PACKAGE VERSION/FreePBX/g' admin/i18n/amp.pot |
|---|
| 104 |
/bin/sed -i 's/charset=CHARSET/charset=utf-8/g' admin/i18n/amp.pot |
|---|
| 105 |
echo "Removing temp files" |
|---|
| 106 |
rm admin/i18n/amp.tmp |
|---|
| 107 |
echo "Done, now don't forget to commit your work!" |
|---|