Re: keys in Aptitude
Quoting Daniel Burrows (d.burrows4@verizon.net):
> > Yep, sure. Maybe someone could come up with a patch, unless Daniel is
> > already aware of the way to properly use this in his source code.
>
> Huh?
Well, gettext includes a method to use localised Yes/No
expressions. For instance, the French locales use "Y", "y", "O",
"o". The yesexpr is "^[oOyY].*" and the noexpr is "^[nN].*" (because
"no" has the same initial then "No").
Below is how this is used in apt. I guess you can get the point from
this. I can't really help myself about this but oter -i18n
contributors may bring you input if you need.
// YnPrompt - Yes No Prompt. /*{{{*/
// ---------------------------------------------------------------------
/* Returns true on a Yes.*/
bool YnPrompt(bool Default=true)
{
if (_config->FindB("APT::Get::Assume-Yes",false) == true)
{
c1out << _("Y") << endl;
return true;
}
char response[1024] = "";
cin.getline(response, sizeof(response));
if (!cin)
return false;
if (strlen(response) == 0)
return Default;
regex_t Pattern;
int Res;
Res = regcomp(&Pattern, nl_langinfo(YESEXPR),
REG_EXTENDED|REG_ICASE|REG_NOSUB);
if (Res != 0) {
char Error[300];
regerror(Res,&Pattern,Error,sizeof(Error));
return _error->Error(_("Regex compilation error - %s"),Error);
}
Res = regexec(&Pattern, response, 0, NULL, 0);
if (Res == 0)
return true;
return false;
}
Reply to: