3 /*=====================================================================*\
4 || ###################################################################
5 || # xgettext For ISSO PHP and Template Files [#]version[#]
6 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
8 || # This program is free software; you can redistribute it and/or modify
9 || # it under the terms of the GNU General Public License as published by
10 || # the Free Software Foundation; version [#]gpl[#] of the License.
12 || # This program is distributed in the hope that it will be useful, but
13 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 || # You should have received a copy of the GNU General Public License along
18 || # with this program; if not, write to the Free Software Foundation, Inc.,
19 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 || ###################################################################
21 \*=====================================================================*/
23 require_once('/Server/htdocs/ISSO/Functions.php');
25 // TODO - process $argv and translate them into xgettext arguments
27 // ###################################################################
28 // generate the list of files to process
30 $filelist = BSFunctions
::ScanDirectory('.');
32 foreach ($filelist AS $dirpath => $nodes)
34 $dirpath = ($dirpath ? BSFunctions
::FetchSourcePath($dirpath) : '');
35 foreach ($nodes AS $file)
37 $ext = BSFunctions
::FetchExtension($file);
40 $files[] = '.' . BSFunctions
::FetchSourcePath($search) . $dirpath . $file;
42 else if ($ext == 'xml' OR $ext == 'tpl' OR $ext == 'html' OR $ext == 'htm')
45 'orig' => '.' . BSFunctions
::FetchSourcePath($search) . $dirpath . $file,
46 'temp' => '.' . BSFunctions
::FetchSourcePath($search) . $dirpath . 'xgtxt-' . $file . '.php'
52 // ###################################################################
53 // compile the templates into gettext-friendly PHP code
55 function process_template_text($text)
57 return '<?php gettext("' . $text . '"); ?>';
60 foreach ($templates AS $paths)
62 $template = file_get_contents($paths['orig']);
64 $template = preg_replace('#\{@\\"(.*?)\\"\}#ise', 'process_template_text(\'$1\')', $template);
66 file_put_contents($paths['temp'], $template);
69 /*=====================================================================*\
70 || ###################################################################
73 || ###################################################################
74 \*=====================================================================*/