summaryrefslogtreecommitdiffstats
path: root/src/cli/report.cpp
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2010-08-27 16:37:54 +0200
committerKarel Klic <kklic@redhat.com>2010-08-27 16:37:54 +0200
commit8c2a382e4b40d6408a9af458f9316e1503701196 (patch)
tree8bb8bdf6dc7b56d17b847e131f22bcc088ac6a48 /src/cli/report.cpp
parent0e8b934e6007545b1a0af0fde11bfca36b72cd6a (diff)
downloadabrt-8c2a382e4b40d6408a9af458f9316e1503701196.tar.gz
abrt-8c2a382e4b40d6408a9af458f9316e1503701196.tar.xz
abrt-8c2a382e4b40d6408a9af458f9316e1503701196.zip
Localization of [y/n] response in abrt-cli
Diffstat (limited to 'src/cli/report.cpp')
-rw-r--r--src/cli/report.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/cli/report.cpp b/src/cli/report.cpp
index 4c5eb6f1..a7606995 100644
--- a/src/cli/report.cpp
+++ b/src/cli/report.cpp
@@ -531,17 +531,24 @@ static vector_string_t get_enabled_reporters(map_crash_data_t &crash_data)
return result;
}
-/* Asks a [y/n] question on stdin/stdout.
+/**
+ * Asks a [y/n] question on stdin/stdout.
* Returns true if the answer is yes, false otherwise.
*/
static bool ask_yesno(const char *question)
{
- printf(question);
+ /* The response might take more than 1 char in non-latin scripts. */
+ const char *yes = _("y");
+ const char *no = _("N");
+ char *full_question = xasprintf("%s [%s/%s]: ", question, yes, no);
+ printf(full_question);
+ free(full_question);
fflush(NULL);
- char answer[16] = "n";
+ char answer[16];
fgets(answer, sizeof(answer), stdin);
- /* TODO: localize 'y' */
- return ((answer[0] | 0x20) == 'y');
+ /* Use strncmp here because the answer might contain a newline as
+ the last char. */
+ return 0 == strncmp(answer, yes, strlen(yes));
}
/* Returns true if echo has been changed from another state. */
@@ -712,7 +719,7 @@ int report(const char *crash_id, int flags)
for (vector_string_t::const_iterator it = reporters.begin(); it != reporters.end(); ++it)
{
char question[255];
- snprintf(question, 255, _("Report using %s? [y/N]: "), it->c_str());
+ snprintf(question, 255, _("Report using %s?"), it->c_str());
if (!ask_yesno(question))
{
puts(_("Skipping..."));