Skip to content

Commit

Permalink
improve the extract to know when there is the same string inside one …
Browse files Browse the repository at this point in the history
…plural tickect #2538
  • Loading branch information
krolow committed Feb 5, 2012
1 parent 606c30b commit 1465b79
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/Cake/Console/Command/Task/ExtractTask.php
Expand Up @@ -74,6 +74,13 @@ class ExtractTask extends Shell {
*/
protected $_strings = array();

/**
* Extracted sigular strings
*
* @var array
*/
protected $_singulars = array();

/**
* Destination path
*
Expand Down Expand Up @@ -322,6 +329,12 @@ protected function _parse($functionName, $map) {
if ($mapCount == count($strings)) {
extract(array_combine($map, $strings));
$domain = isset($domain) ? $domain : 'default';
if (isset($plural)) {
if (!isset($_this->_singulars)) {
$this->_singulars[$domain] = array();
}
array_push($this->_singulars[$domain], $singular);
}
$string = isset($plural) ? $singular . "\0" . $plural : $singular;
$this->_strings[$domain][$string][$this->_file][] = $line;
} else {
Expand Down Expand Up @@ -422,7 +435,10 @@ protected function _buildFiles() {
$header = '#: ' . str_replace($this->_paths, '', $occurrences) . "\n";

if (strpos($string, "\0") === false) {
$sentence = "msgid \"{$string}\"\n";
if (isset($this->_singulars[$domain]) && in_array($string, $this->_singulars[$domain])) {
continue;
}
$sentence = "msgid \"{$string}\"\n";
$sentence .= "msgstr \"\"\n\n";
} else {
list($singular, $plural) = explode("\0", $string);
Expand Down

0 comments on commit 1465b79

Please sign in to comment.