[PATCH 0 of 1] ui: add function 'promptselection'
Ingo Proetel
proetel at aicas.de
Thu Aug 4 10:17:41 CDT 2011
I guess it could be fixed by adding the command separately instead of
inferring it:
choices = (('abort',_('&Abort command')),
('new', _('Create &new, request')),
('reopen', _('&Reopen request')) )
request = ui.promptselection(_('now what?'), choices,'new')
Ingo
Am 04.08.2011 15:02, schrieb timeless:
> 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
>>
>
--
aicas GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com * Tel: +49-721-663 968-0
USt-Id: DE216375633, Handelsregister HRB 109481, AG Mannheim
Geschäftsführer: Dr. James J. Hunt
More information about the Mercurial-devel
mailing list