-#include "AliveCursor.h"
-#include "zypper.h"
-
#include <ctype.h>
#include <sstream>
+#include <boost/format.hpp>
+
+#include "AliveCursor.h"
+#include "zypper.h"
+
using namespace std;
+using namespace boost;
void display_progress ( const std::string &id, ostream & out, const string& s, int percent) {
static AliveCursor cursor;
// ----------------------------------------------------------------------------
-// Read an answer (ynYN)
bool read_bool_answer(const string & question, bool default_answer)
{
if (!gSettings.machine_readable)
istream & stm = cin;
string c = "";
- while (stm.good () && c != "y" && c != "Y" && c != "N" && c != "n")
+ bool been_here_before = false;
+ while (stm.good ()
+ // TranslatorExplanation This is a Lowercase 'y' for "yes" used as an
+ // answer in y/n prompts. Translate to the same letter as you translated
+ // it in the "[y/n]" string!.
+ && c != _("y")
+ // TranslatorExplanation Uppercase 'Y' for "yes" used as an
+ // answer in y/n prompts. Translate to the same letter as you translated
+ // it in the "[y/n]" string!.
+ && c != _("Y")
+ // TranslatorExplanation Lowercase 'n' for "no" used as an
+ // answer in y/n prompts. Translate to the same letter as you translated
+ // it in the "[y/n]" string!.
+ && c != _("n")
+ // TranslatorExplanation Uppercase 'N' for "no" used as an
+ // answer in y/n prompts. Translate to the same letter as you translated
+ // it in the "[y/n]" string!.
+ && c != _("N"))
+ {
+ if (been_here_before)
+ // TranslatorExplanation Example: Invalid answer 'x', enter 'y' or 'n':
+ cerr << format(_("Invalid answer '%s', enter '%s' or '%s':"))
+ % c % _("y") % _("n") << " ";
c = zypp::str::getline (stm, zypp::str::TRIM);
+ been_here_before = true;
+ }
MIL << "answer: " << c << endl;
- if (c == "y" || c == "Y")
+ if (c == _("y") || c == _("Y"))
return true;
- else if (c == "n" || c == "N")
+ else if (c == _("n") || c == _("N"))
return false;
else
{
int read_action_ari (int default_action = -1);
/**
- * Prompt for Yes/No answer from stdin.
+ * Prompt for y/n answer (localized) from stdin.
*
* \param question Question to be printed on prompt.
* \param default_answer Value to be returned in non-interactive mode or on
* input failure.
- *
- * \todo make this localized
*/
bool read_bool_answer(const string & question, bool default_answer);