Skip to content
Permalink
Browse files

Fixing typo and introducing 'Overwrite all' functionallity. Fixes #333.

  • Loading branch information...
renan committed Feb 18, 2010
1 parent 42a5665 commit 14911cf720e16acdd155c3c52c36470478c07cd2
Showing with 17 additions and 15 deletions.
  1. +17 −15 cake/console/libs/tasks/extract.php
@@ -321,12 +321,12 @@ function __parse($functionName, $map) {
function __buildFiles() {
foreach ($this->__strings as $domain => $strings) {
foreach ($strings as $string => $files) {
$occurences = array();
$occurrences = array();
foreach ($files as $file => $lines) {
$occurences[] = $file . ':' . implode(';', $lines);
$occurrences[] = $file . ':' . implode(';', $lines);
}
$occurences = implode("\n#: ", $occurences);
$header = '#: ' . str_replace($this->__paths, '', $occurences) . "\n";
$occurrences = implode("\n#: ", $occurrences);
$header = '#: ' . str_replace($this->__paths, '', $occurrences) . "\n";
if (strpos($string, "\0") === false) {
$sentence = "msgid \"{$string}\"\n";
@@ -371,6 +371,7 @@ function __store($domain, $header, $sentence) {
* @access private
*/
function __writeFiles() {
$overwriteAll = false;
foreach ($this->__storage as $domain => $sentences) {
$output = $this->__writeHeader();
foreach ($sentences as $sentence => $header) {
@@ -379,18 +380,19 @@ function __writeFiles() {
$filename = $domain . '.pot';
$File = new File($this->__output . $filename);
if ($File->exists()) {
$response = '';
while ($response == '') {
$this->out();
$response = $this->in(sprintf(__('Error: %s already exists in this location. Overwrite?', true), $filename), array('y', 'n'), 'y');
if (strtoupper($response) === 'N') {
$response = '';
while ($response == '') {
$response = $this->in(sprintf(__("What would you like to name this file?\nExample: %s", true), 'new_' . $filename), null, 'new_' . $filename);
$File = new File($this->__output . $response);
}
$response = '';
while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') {
$this->out();
$response = $this->in(sprintf(__('Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll', true), $filename), array('y', 'n', 'a'), 'y');
if (strtoupper($response) === 'N') {
$response = '';
while ($response == '') {
$response = $this->in(sprintf(__("What would you like to name this file?\nExample: %s", true), 'new_' . $filename), null, 'new_' . $filename);
$File = new File($this->__output . $response);
$filename = $response;
}
} elseif (strtoupper($response) === 'A') {
$overwriteAll = true;
}
}
$File->write($output);

0 comments on commit 14911cf

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