root/freepbx/branches/2.5/update_i18n.sh

Revision 7226, 2.2 kB (checked in by mickecarlsson, 4 years ago)

Added a tool to autocreate all .pot files for amp and all modules

  • 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   /var/lib/asterisk/bin/module_admin i18n ${modules%%/} > $modules${modules%%/}.i18n.php
32   echo "Creating ${modules%%/}.pot file, extracting text strings"
33   find ${modules%%/}/*.php | xargs xgettext -L PHP -o ${modules%%/}/i18n/${modules%%/}.pot --keyword=_ -
34   echo "Removing temp file"
35   rm $modules${modules%%/}.i18n.php
36   fi
37 done
38 # Go back two directory levels
39 cd ../..
40 echo "Creating new POT template files for core"
41 # spit out the module.xml for core to amp.i18.php so that we can grab it with the find
42 /var/lib/asterisk/bin/module_admin i18n core > admin/modules/core/core.i18n.php
43 find admin/*.php admin/cdr/*.php admin/views/*.php admin/common/*.php admin/modules/core/*.php -maxdepth 0 | xargs xgettext -L PHP -o admin/i18n/amp.pot --keyword=_ -
44 # remove the <modulename>.i18.php
45 rm admin/modules/core/core.i18n.php
46 echo "Done, now don't forget to commit your work!"
Note: See TracBrowser for help on using the browser.