Improve the extract to know when there is the same string inside one plural

Fixes #2538
This commit is contained in:
Vinícius Krolow 2012-02-05 21:38:08 -02:00 committed by mark_story
parent e44d36f8db
commit fa5f175244

View file

@ -76,6 +76,13 @@ class ExtractTask extends AppShell {
*/
protected $_strings = array();
/**
* Extracted sigular strings
*
* @var array
*/
protected $_singulars = array();
/**
* Destination path
*
@ -325,6 +332,12 @@ class ExtractTask extends AppShell {
if ($mapCount == count($strings)) {
extract(array_combine($map, $strings));
$domain = isset($domain) ? $domain : 'default';
if (isset($plural)) {
if (!isset($_this->_singulars[$domain])) {
$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 {
@ -428,7 +441,10 @@ class ExtractTask extends AppShell {
$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);