[PATCH 0 of 1] ui: add function 'promptselection'
timeless
timeless at gmail.com
Thu Aug 4 08:02:58 CDT 2011
Your proposal is likely to break horribly in most localizations.
In order to use it, I'd have to do:
yes = _('Yes')
no = _('No')
maybe = _('Maybe')
response = ui.promptselection(_('should this be done?'), (yes, no, maybe), no)
if response is yes:
...
Any other construct is l10n fragile - localizers can easily not
recognize that two strings must be identical.
-1.
On 8/4/11, Ingo Proetel <proetel at aicas.de> wrote:
> Hello,
>
> I have a patch proposal for a new function to replace 'promptchoice'.
>
> The function 'promptselection' provides more automatic support for user
> selections:
> - always provide a help
> - uniform representation of possible choices
> - return command strings instead of indexes
>
> Its use is similar to 'promptchoice':
> choices = (_('&Abort command'),
> _('Create &new request'),
> _('&Reopen request') )
> request = ui.promptselection('now what?', choices,'new')
> if request == 'abort':
> util.Abort('User aborted')
> elif request == 'new':
> ui.status('creating new')
> else:#request == 'reopen'
> ui.status('reopen existing')
>
> The output will look like this:
> $>now what? [aNr?] ?
> a Abort command
> n Create new request
> r Reopen request
> $>now what? [aNr?] n
> creating new
>
> If this function was accepted I would go through all uses of 'promptchoice'
> and replace them.
>
> Best Regards,
> Ingo
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
--
Sent from my mobile device
More information about the Mercurial-devel
mailing list