From 7eb3abb08a0b20bef49a9bf717ea30fad27c5606 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Mon, 28 May 2012 04:50:38 +0200 Subject: src/custom.c: Use status_ask_simplechoice() This eases up i18n somewhat, since the various date format available are used on other places as well, and thus need to be translated only once. Note that this commit incidentally fixes a small bug introduced by 38912b36: the user was able to set the date input format to a number between 1 and 5, while there are only 4 such formats available. Signed-off-by: Baptiste Jonglez Signed-off-by: Lukas Fleischer --- src/custom.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/custom.c b/src/custom.c index fd93a11..b8bd89b 100644 --- a/src/custom.c +++ b/src/custom.c @@ -714,12 +714,17 @@ void custom_general_config(void) const char *keys = _("(Press '^P' or '^N' to move up or down, 'Q' to quit)"); const char *output_datefmt_str = _("Enter the date format (see 'man 3 strftime' for possible formats) "); - const char *input_datefmt_str = - _("Enter the date format (1)mm/dd/yyyy (2)dd/mm/yyyy (3)yyyy/mm/dd " - "(4)yyyy-mm-dd"); + const char *input_datefmt_prefix = _("Enter the date format: "); + const char *input_datefmt_choices[] = { + _("mm/dd/yyyy"), + _("dd/mm/yyyy"), + _("yyyy/mm/dd"), + _("yyyy-mm-dd") + }; const char *periodic_save_str = _("Enter the delay, in minutes, between automatic saves (0 to disable) "); int ch; + int val; char *buf; clear(); @@ -751,7 +756,7 @@ void custom_general_config(void) case '3': status_mesg(periodic_save_str, ""); if (updatestring(win[STA].p, &buf, 0, 1) == 0) { - int val = atoi(buf); + val = atoi(buf); if (val >= 0) conf.periodic_save = val; if (conf.periodic_save > 0) @@ -785,13 +790,11 @@ void custom_general_config(void) status_mesg(number_str, keys); break; case '0': - status_mesg(input_datefmt_str, ""); - if (updatestring(win[STA].p, &buf, 0, 1) == 0) { - int val = atoi(buf); - if (val > 0 && val <= DATE_FORMATS) - conf.input_datefmt = val; - } - status_mesg(number_str, keys); + val = status_ask_simplechoice(input_datefmt_prefix, + input_datefmt_choices, + DATE_FORMATS - 1); + if (val != -1) + conf.input_datefmt = val; break; } -- cgit v1.2.3-70-g09d2