1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?php
/**
* Lookup for second argument in functions _t() and _d() in source code
*
* PHP 5.3
*
* @license MIT
* @author Filip (transformation to build a gettext dictionary)
* @copyright 2014/02
* based on extract2lang.php by author Romain d'Alverny, rdalverny, rda
*/
if (php_sapi_name() !== 'cli') {
echo "CLI only.\n";
exit(1);
}
if (version_compare(PHP_VERSION, '5.3.0') < 0) {
echo "PHP 5.3 needed.\n";
exit(1);
}
$php_source = isset($argv[1]) ? $argv[1] : null;
$domain = isset($argv[2]) ? $argv[2] : null;
if (is_null($php_source) || is_null($domain)) {
echo <<<U
Usage:
php tools/lookup_for_second_argument.php path/to/source.php domain_name
Example:
php tools/lookup_for_second_argument.php en/index.php index
You can join multiple sources with apostrophe - single quote (') like this:
'en/3/download_index.php en/for-pc/index.php en/for-server/index.php en/3/index.php en/3/nav.php'
U;
exit(1);
}
date_default_timezone_set(@date_default_timezone_get());
$cmd = sprintf('grep -HrnEi "_(e|t|h|d)\((.*)" %s', $php_source);
exec($cmd, $out);
foreach ($out as $str) {
$arr = explode(':', $str);
$file = array_shift($arr);
$line = array_shift($arr);
$arr = implode(':', $arr);
$arr = str_replace('\\\'', '_apostrophe_', $arr);
if (preg_match_all('/\_(t|d)\(\'(.+)\'(,.+)$/im', $arr, $test)) { // qq i=PCRE_CASELESS, m=PCRE_MULTILINE, U=PCRE_UNGREEDY
foreach ($test[3] as $more_arg) { // qq
$att = $php_source . ' (line ' . $line . '): '. trim($arr) . PHP_EOL; // qq
$attention[] = $att;
echo $att . PHP_EOL;
}
}
}
exit(0);
|