8000 Added i18n support to ConfirmationQuestion · symfony/symfony@2ca18fc · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ca18fc

Browse files
committed
Added i18n support to ConfirmationQuestion
1 parent f4a087b commit 2ca18fc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Symfony/Component/Console/Question/ConfirmationQuestion.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@
1818
*/
1919
class ConfirmationQuestion extends Question
2020
{
21-
public function __construct($question, $default = true)
21+
private $trueAnswer;
22+
23+
public function __construct($question, $default = true, $trueAnswer = 'y')
2224
{
2325
parent::__construct($question, (bool) $default);
2426

2527
$this->setNormalizer($this->getDefaultNormalizer());
28+
29+
$this->trueAnswer = strtolower($trueAnswer);
2630
}
2731

2832
private function getDefaultNormalizer()
@@ -34,11 +38,12 @@ private function getDefaultNormalizer()
3438
return $answer;
3539
}
3640

41+
$answerIsTrue = $this->trueAnswer === strtolower(substr($answer, 0, strlen($this->trueAnswer)));
3742
if (false === $default) {
38-
return $answer && 'y' === strtolower($answer[0]);
43+
return $answer && $answerIsTrue;
3944
}
4045

41-
return !$answer || 'y' === strtolower($answer[0]);
46+
return !$answer || $answerIsTrue;
4247
};
4348
}
4449
}

0 commit comments

Comments
 (0)
0