Update version.php to 3.3.0
[isso.git] / docs / makepo.sh.php
1 #!/usr/bin/php
2 <?php
3 /*=====================================================================*\
4 || ###################################################################
5 || # xgettext For ISSO PHP and Template Files
6 || # Copyright (c)2005-2009 Iris Studios, Inc.
7 || #
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 2 of the License.
11 || #
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
15 || # more details.
16 || #
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 \*=====================================================================*/
22
23 require_once('/usr/local/apache2/htdocs/ISSO/Functions.php');
24
25 // ###################################################################
26 // generate the list of files to process
27
28 $filelist = BSFunctions::scan_directory('.');
29
30 foreach ($filelist as $file)
31 {
32 $ext = BSFunctions::fetch_extension($file);
33 if ($ext == 'php')
34 {
35 $files[dirname($file)] = BSFunctions::fetch_source_path(dirname($file)) . '*.php';
36 }
37 else if ($ext == 'xml' || $ext == 'tpl' || $ext == 'html' || $ext == 'htm')
38 {
39 $files[dirname($file)] = BSFunctions::fetch_source_path(dirname($file)) . '*.php';
40 $templates[] = array(
41 'orig' => BSFunctions::fetch_source_path('./' . $dirpath) . $file,
42 'temp' => BSFunctions::fetch_source_path('./' . $dirpath) . $file . '.xgt.php'
43 );
44 }
45 }
46
47 // ###################################################################
48 // compile the templates into gettext-friendly PHP code
49
50 function process_template_text($text)
51 {
52 return '<?php gettext("' . $text . '"); ?>';
53 }
54
55 foreach ($templates as $paths)
56 {
57 $template = file_get_contents($paths['orig']);
58
59 $template = preg_replace('#\{@\\"(.*?)\\"\}#ise', 'process_template_text(\'$1\')', $template);
60
61 file_put_contents($paths['temp'], $template);
62
63 $removelater[] = $paths['temp'];
64 }
65
66 // ###################################################################
67 // run xgettext on all of the various files that we have now created
68
69 // get any arguments and just pass them to xgettext
70 $arguments = $argv;
71 unset($arguments[0]);
72
73 exec('xgettext ' . implode(' ', $arguments) . ' ' . implode(' ', $files));
74
75 // ###################################################################
76 // remove all the files we no longer need
77
78 foreach ($removelater as $path)
79 {
80 unlink($path);
81 }
82
83 ?>