[PATCH 1 of 2] record: refactored prompt choices to clean code and offer better choices
Wagner Bruna
wagner.bruna+mercurial at gmail.com
Thu Feb 23 14:24:39 UTC 2012
On 02/23/2012 09:44 AM, A. S. Budden wrote:
> On 23 February 2012 11:23, timeless <timeless at gmail.com> wrote:
>> So. Localized command letters can be an interesting disaster. -
>> Especially for users likely to switch between en and some other
>> language that uses Latin letters (it's a *different* disaster for non
>> Latin languages...).
>
> Okay. This does beg the question: how do you cope if the translated
> string doesn't contain the prompt letter? I guess one alternative
> would be to use the prompt string:
>
> &s - skip remaining changes to this file
>
> and translate it to (obviously there are several 's's in this example,
> but that's beside the point):
>
> &s - überspringe die restlichen änderungen an dieser datei
>
> You could then implement it as something like (not tested):
>
> choices = ('Y', _('record this change'),
> 'n', _('skip this change'),
> 's', _('skip remaining changes to this file'),
> 'f', _('record remaining changes to this file'),
> 'd', _('skip remaining changes and files'),
> 'a', _('record all changes to all remaining files'),
> 'q', _('quit, recording no changes'),
> '?', _('show help'))
> prompts = ['&%s - %s' % x for x in choices]
> keychars = ''.join([x[0] for x in choices])
> r = ui.promptchoice('%s [%s]' % (query, keychars), prompts)
> # ...
> # ...
> if choices[r][0] == '?':
> # Help text is the same as prompts but without the & and
> joined by new-lines
> ui.write(''.join(['%s - %s\n' % x for x in choices]))
>
> Thoughts?
<puts translator hat on>
IMHO that would be an improvement, yes. But see
http://selenic.com/pipermail/mercurial-devel/2011-September/034423.html
for a previous discussion about translating prompt keys.
Regards,
Wagner
More information about the Mercurial-devel
mailing list