Mercurial > hg-stable
changeset 7015:6651de7176a0
i18n, record: improve use of translated docstring in prompts
The old code would confuse the user if the translator actually
translated the letters "Ynsfdaq?" in the prompt, since the user input
would be matched against the English string, despite the translation.
The new code fixes this, but the translator must be 100% consistent.
Also, the translation of single character strings is problematic if
they are used differently by different pieces of code.
author | Martin Geisler <mg@daimi.au.dk> |
---|---|
date | Tue, 09 Sep 2008 21:32:39 +0200 |
parents | 46456a51e247 |
children | 8362086a1227 |
files | hgext/record.py |
diffstat | 1 files changed, 16 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/record.py Tue Sep 09 21:32:39 2008 +0200 +++ b/hgext/record.py Tue Sep 09 21:32:39 2008 +0200 @@ -7,7 +7,7 @@ '''interactive change selection during commit or qrefresh''' -from mercurial.i18n import _ +from mercurial.i18n import gettext, _ from mercurial import cmdutil, commands, extensions, hg, mdiff, patch from mercurial import util import copy, cStringIO, errno, operator, os, re, tempfile @@ -282,22 +282,24 @@ if resp_file[0] is not None: return resp_file[0] while True: - r = (ui.prompt(query + _(' [Ynsfdaq?] '), '(?i)[Ynsfdaq?]?$') - or 'y').lower() - if r == '?': - c = record.__doc__.find('y - record this change') - for l in record.__doc__[c:].splitlines(): - if l: ui.write(_(l.strip()), '\n') + choices = _('[Ynsfdaq?]') + r = (ui.prompt("%s %s " % (query, choices), '(?i)%s?$' % choices) + or _('y')).lower() + if r == _('?'): + doc = gettext(record.__doc__) + c = doc.find(_('y - record this change')) + for l in doc[c:].splitlines(): + if l: ui.write(l.strip(), '\n') continue - elif r == 's': + elif r == _('s'): r = resp_file[0] = 'n' - elif r == 'f': + elif r == _('f'): r = resp_file[0] = 'y' - elif r == 'd': + elif r == _('d'): r = resp_all[0] = 'n' - elif r == 'a': + elif r == _('a'): r = resp_all[0] = 'y' - elif r == 'q': + elif r == _('q'): raise util.Abort(_('user quit')) return r while chunks: @@ -315,7 +317,7 @@ chunk.pretty(ui) r = prompt(_('examine changes to %s?') % _(' and ').join(map(repr, chunk.files()))) - if r == 'y': + if r == _('y'): applied[chunk.filename()] = [chunk] if chunk.allhunks(): applied[chunk.filename()] += consumefile() @@ -327,7 +329,7 @@ chunk.pretty(ui) r = prompt(_('record this change to %r?') % chunk.filename()) - if r == 'y': + if r == _('y'): if fixoffset: chunk = copy.copy(chunk) chunk.toline += fixoffset