7 require_once
"xgettextCommon.php";
13 $this->tokenFile = token_get_all(file_get_contents($inputFile));
15 $filteredLabel = preg_filter(
"/.*@(searchLabel)\\s+([^\\n]+)\\n.*/s",
"\\2", array_map(
function ($t)
19 , array_filter($this->tokenFile,
function ($t)
21 return ($t[0] === T_DOC_COMMENT);
24 return $filteredLabel;
29 $filteredLabel = array();
31 $filteredSharp = array_filter($this->tokenFile,
function ($t)
33 return ($t[0] === T_COMMENT && $t[1][0] ===
'#');
35 foreach ($filteredSharp as $sharpComment) {
36 $sharpComment[1][0] =
' ';
37 if (preg_match_all(
'/\sN?_\("([^\)]+)"\)/', $sharpComment[1], $matches)) {
38 foreach ($matches[1] as $m) {
39 $filteredLabel[] = $m;
43 return $filteredLabel;
49 $phpFile = $potFile .
"_searchlabel_.php";
50 $searchLabel = array();
51 $sharpLabel = array();
52 foreach ($this->inputFiles as $k => $phpInputFile) {
53 $phpInputFile = trim($phpInputFile);
55 unset($this->inputFiles[$k]);
59 $searchLabel = array_merge($searchLabel, $labels);
61 $sharpLabel = array_merge($sharpLabel, $labels);
63 $searchPhp =
"<?php\n";
64 foreach ($searchLabel as $label) {
65 $searchPhp.= sprintf(
"\n// _COMMENT Search Label\n");
66 $searchPhp.= sprintf(
'$a=_("%s");', preg_replace(
'/"/',
'\"', $label));
68 foreach ($sharpLabel as $label) {
69 $searchPhp.= sprintf(
"\n// _COMMENT Sharp Label\n");
70 $searchPhp.= sprintf(
'$a=_("%s");', preg_replace(
'/"/',
'\"', $label));
73 file_put_contents($phpFile, $searchPhp);
74 $inputFilesArgs = array_map(
"escapeshellarg", $this->inputFiles);
75 $cmd = sprintf(
'xgettext \
81 --add-comments=_COMMENT \
85 --keyword=pgettext:1,2 \
86 --keyword=n___:1,2,4c \
87 --keyword=npgettext:1,2,4c \
91 %s -o %s %s %s && rm %s', $this->getXoptions() , escapeshellarg($potFile) , join(
' ', $inputFilesArgs) , escapeshellarg($phpFile) , escapeshellarg($phpFile));
extractExtraLabel($inputFile)
foreach($argv as $arg) $cmd