Skip to content
Permalink
Browse files

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

…plural

Fixes #2538
  • Loading branch information...
krolow authored and markstory committed Feb 5, 2012
1 parent e44d36f commit fa5f17524428a9532d5b3168ab9d898bf0e0e61d
Showing with 17 additions and 1 deletion.
  1. +17 −1 lib/Cake/Console/Command/Task/ExtractTask.php
@@ -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 @@ 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[$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 @@ 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);

0 comments on commit fa5f175

Please sign in to comment.
You can’t perform that action at this time.