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

This commit is contained in:
renan.saddam 2010-02-17 21:41:15 -03:00
parent 42a5665660
commit 14911cf720

View file

@ -321,12 +321,12 @@ class ExtractTask extends Shell {
function __buildFiles() { function __buildFiles() {
foreach ($this->__strings as $domain => $strings) { foreach ($this->__strings as $domain => $strings) {
foreach ($strings as $string => $files) { foreach ($strings as $string => $files) {
$occurences = array(); $occurrences = array();
foreach ($files as $file => $lines) { foreach ($files as $file => $lines) {
$occurences[] = $file . ':' . implode(';', $lines); $occurrences[] = $file . ':' . implode(';', $lines);
} }
$occurences = implode("\n#: ", $occurences); $occurrences = implode("\n#: ", $occurrences);
$header = '#: ' . str_replace($this->__paths, '', $occurences) . "\n"; $header = '#: ' . str_replace($this->__paths, '', $occurrences) . "\n";
if (strpos($string, "\0") === false) { if (strpos($string, "\0") === false) {
$sentence = "msgid \"{$string}\"\n"; $sentence = "msgid \"{$string}\"\n";
@ -371,6 +371,7 @@ class ExtractTask extends Shell {
* @access private * @access private
*/ */
function __writeFiles() { function __writeFiles() {
$overwriteAll = false;
foreach ($this->__storage as $domain => $sentences) { foreach ($this->__storage as $domain => $sentences) {
$output = $this->__writeHeader(); $output = $this->__writeHeader();
foreach ($sentences as $sentence => $header) { foreach ($sentences as $sentence => $header) {
@ -379,18 +380,19 @@ class ExtractTask extends Shell {
$filename = $domain . '.pot'; $filename = $domain . '.pot';
$File = new File($this->__output . $filename); $File = new File($this->__output . $filename);
if ($File->exists()) { $response = '';
$response = ''; while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') {
while ($response == '') { $this->out();
$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');
$response = $this->in(sprintf(__('Error: %s already exists in this location. Overwrite?', true), $filename), array('y', 'n'), 'y'); if (strtoupper($response) === 'N') {
if (strtoupper($response) === 'N') { $response = '';
$response = ''; while ($response == '') {
while ($response == '') { $response = $this->in(sprintf(__("What would you like to name this file?\nExample: %s", true), 'new_' . $filename), null, 'new_' . $filename);
$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);
$File = new File($this->__output . $response); $filename = $response;
}
} }
} elseif (strtoupper($response) === 'A') {
$overwriteAll = true;
} }
} }
$File->write($output); $File->write($output);