root/freepbx/branches/2.7/update_i18n.sh

Revision 9258, 4.7 kB (checked in by mickecarlsson, 3 years ago)

Updated tool with --no-location option when creating .pot files

  • Property svn:executable set to *
Line 
1 #! /bin/sh
2 # Copyright (c) 2008 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 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   echo "Removing temp files"
64   rm $modules${modules%%/}.i18n.php
65   rm ${modules%%/}/i18n/${modules%%/}.tmp
66   fi
67 done
68 # Go back two directory levels
69 cd ../..
70 echo "Creating new POT template files for core"
71 # spit out the module.xml for core to amp.i18.php so that we can grab it with the find
72 /var/lib/asterisk/bin/module_admin i18n core > admin/modules/core/core.i18n.php
73 find admin/*.php admin/cdr/*.php admin/views/*.php admin/common/*.php admin/modules/core/*.php -maxdepth 0 | xargs xgettext --no-location -L PHP -o admin/i18n/amp.pot --keyword=_ -
74 # remove the <modulename>.i18.php
75 rm admin/modules/core/core.i18n.php
76 echo "Done, now don't forget to commit your work!"
Note: See TracBrowser for help on using the browser.