Line | |
---|
1 | #!/usr/bin/env php |
---|
2 | <?php |
---|
3 | $license_block = <<<EOF |
---|
4 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
5 | # |
---|
6 | # This file is part of Dotclear 2. |
---|
7 | # |
---|
8 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
---|
9 | # Licensed under the GPL version 2.0 license. |
---|
10 | # See LICENSE file or |
---|
11 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
12 | # |
---|
13 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
14 | EOF; |
---|
15 | |
---|
16 | require dirname(__FILE__).'/../inc/libs/clearbricks/common/lib.l10n.php'; |
---|
17 | |
---|
18 | $path = (!empty($_SERVER['argv'][1])) ? $_SERVER['argv'][1] : getcwd(); |
---|
19 | $path = realpath($path); |
---|
20 | |
---|
21 | $cmd = 'find '.$path.' -type f -name \'*.po\''; |
---|
22 | exec($cmd,$eres,$ret); |
---|
23 | |
---|
24 | $res = array(); |
---|
25 | |
---|
26 | foreach ($eres as $f) |
---|
27 | { |
---|
28 | $dest = dirname($f).'/'.basename($f,'.po').'.lang.php'; |
---|
29 | echo "l10n file ".$dest.": "; |
---|
30 | |
---|
31 | $l = l10n::getPoFile($f); |
---|
32 | |
---|
33 | $fcontent = |
---|
34 | "<?php\n". |
---|
35 | $license_block. |
---|
36 | "#\n#\n#\n". |
---|
37 | "# DOT NOT MODIFY THIS FILE !\n\n\n\n\n"; |
---|
38 | |
---|
39 | foreach (l10n::getPoFile($f) as $vo => $tr) { |
---|
40 | $vo = str_replace("'","\\'",$vo); |
---|
41 | $tr = str_replace("'","\\'",$tr); |
---|
42 | $fcontent .= '$GLOBALS[\'__l10n\'][\''.$vo.'\'] = \''.$tr.'\';'."\n"; |
---|
43 | } |
---|
44 | |
---|
45 | $fcontent .= "?>"; |
---|
46 | |
---|
47 | echo $dest.' : '; |
---|
48 | if (($fp = fopen($dest,'w')) !== false) { |
---|
49 | fwrite($fp,$fcontent,strlen($fcontent)); |
---|
50 | fclose($fp); |
---|
51 | echo 'OK'; |
---|
52 | } else { |
---|
53 | echo 'FAILED'; |
---|
54 | } |
---|
55 | echo "\n"; |
---|
56 | } |
---|
57 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.