Mercurial > hg-stable
comparison hgext/record.py @ 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 | 98abbcf9fbdf |
children | b6f5490effbf |
comparison
equal
deleted
inserted
replaced
7014:46456a51e247 | 7015:6651de7176a0 |
---|---|
5 # This software may be used and distributed according to the terms of | 5 # This software may be used and distributed according to the terms of |
6 # the GNU General Public License, incorporated herein by reference. | 6 # the GNU General Public License, incorporated herein by reference. |
7 | 7 |
8 '''interactive change selection during commit or qrefresh''' | 8 '''interactive change selection during commit or qrefresh''' |
9 | 9 |
10 from mercurial.i18n import _ | 10 from mercurial.i18n import gettext, _ |
11 from mercurial import cmdutil, commands, extensions, hg, mdiff, patch | 11 from mercurial import cmdutil, commands, extensions, hg, mdiff, patch |
12 from mercurial import util | 12 from mercurial import util |
13 import copy, cStringIO, errno, operator, os, re, tempfile | 13 import copy, cStringIO, errno, operator, os, re, tempfile |
14 | 14 |
15 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)') | 15 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)') |
280 if resp_all[0] is not None: | 280 if resp_all[0] is not None: |
281 return resp_all[0] | 281 return resp_all[0] |
282 if resp_file[0] is not None: | 282 if resp_file[0] is not None: |
283 return resp_file[0] | 283 return resp_file[0] |
284 while True: | 284 while True: |
285 r = (ui.prompt(query + _(' [Ynsfdaq?] '), '(?i)[Ynsfdaq?]?$') | 285 choices = _('[Ynsfdaq?]') |
286 or 'y').lower() | 286 r = (ui.prompt("%s %s " % (query, choices), '(?i)%s?$' % choices) |
287 if r == '?': | 287 or _('y')).lower() |
288 c = record.__doc__.find('y - record this change') | 288 if r == _('?'): |
289 for l in record.__doc__[c:].splitlines(): | 289 doc = gettext(record.__doc__) |
290 if l: ui.write(_(l.strip()), '\n') | 290 c = doc.find(_('y - record this change')) |
291 for l in doc[c:].splitlines(): | |
292 if l: ui.write(l.strip(), '\n') | |
291 continue | 293 continue |
292 elif r == 's': | 294 elif r == _('s'): |
293 r = resp_file[0] = 'n' | 295 r = resp_file[0] = 'n' |
294 elif r == 'f': | 296 elif r == _('f'): |
295 r = resp_file[0] = 'y' | 297 r = resp_file[0] = 'y' |
296 elif r == 'd': | 298 elif r == _('d'): |
297 r = resp_all[0] = 'n' | 299 r = resp_all[0] = 'n' |
298 elif r == 'a': | 300 elif r == _('a'): |
299 r = resp_all[0] = 'y' | 301 r = resp_all[0] = 'y' |
300 elif r == 'q': | 302 elif r == _('q'): |
301 raise util.Abort(_('user quit')) | 303 raise util.Abort(_('user quit')) |
302 return r | 304 return r |
303 while chunks: | 305 while chunks: |
304 chunk = chunks.pop() | 306 chunk = chunks.pop() |
305 if isinstance(chunk, header): | 307 if isinstance(chunk, header): |
313 seen[hdr] = True | 315 seen[hdr] = True |
314 if resp_all[0] is None: | 316 if resp_all[0] is None: |
315 chunk.pretty(ui) | 317 chunk.pretty(ui) |
316 r = prompt(_('examine changes to %s?') % | 318 r = prompt(_('examine changes to %s?') % |
317 _(' and ').join(map(repr, chunk.files()))) | 319 _(' and ').join(map(repr, chunk.files()))) |
318 if r == 'y': | 320 if r == _('y'): |
319 applied[chunk.filename()] = [chunk] | 321 applied[chunk.filename()] = [chunk] |
320 if chunk.allhunks(): | 322 if chunk.allhunks(): |
321 applied[chunk.filename()] += consumefile() | 323 applied[chunk.filename()] += consumefile() |
322 else: | 324 else: |
323 consumefile() | 325 consumefile() |
325 # new hunk | 327 # new hunk |
326 if resp_file[0] is None and resp_all[0] is None: | 328 if resp_file[0] is None and resp_all[0] is None: |
327 chunk.pretty(ui) | 329 chunk.pretty(ui) |
328 r = prompt(_('record this change to %r?') % | 330 r = prompt(_('record this change to %r?') % |
329 chunk.filename()) | 331 chunk.filename()) |
330 if r == 'y': | 332 if r == _('y'): |
331 if fixoffset: | 333 if fixoffset: |
332 chunk = copy.copy(chunk) | 334 chunk = copy.copy(chunk) |
333 chunk.toline += fixoffset | 335 chunk.toline += fixoffset |
334 applied[chunk.filename()].append(chunk) | 336 applied[chunk.filename()].append(chunk) |
335 else: | 337 else: |