[PATCH i18n stable] i18n: fix untranslated prompts with translated responses (issue3936)
Matt Mackall
mpm at selenic.com
Tue May 21 10:39:25 CDT 2013
On Mon, 2013-05-20 at 19:51 -0300, Wagner Bruna wrote:
> Em 16-05-2013 15:58, Matt Mackall escreveu:
> > On Wed, 2013-05-15 at 21:37 -0500, Kevin Bullock wrote:
> >> # HG changeset patch
> >> # User Kevin Bullock <kbullock at ringworld.org>
> >> # Date 1368671779 18000
> >> # Wed May 15 21:36:19 2013 -0500
> >> # Branch stable
> >> # Node ID fc1c4221dd82de958b9be5f05c57622679625d21
> >> # Parent 278057693a1ddb93f95fa641e30e7a966ac98434
> >> i18n: fix untranslated prompts with translated responses (issue3936)
> >
> > Queued for stable, thanks.
> >
> > I'd like to see a consensus among translators on how to do this.
>
> IMHO we should always accept the English keys, even with translated prompts
> (to help with muscle memory). And, ideally, detect conflicts at build_mo time.
>
> > I also thing we should unify all the string args used by prompt() into a
> > single string so that translators have the full context.
>
> Seems like a good approach (as long as we ensure there's no paragraph boundary
> on that single string, of course).
Ok, here's a typical use:
elif repo.ui.promptchoice(
_("local changed %s which remote deleted\n"
"use (c)hanged version or (d)elete?") % f,
(_("&Changed"), _("&Delete")), 0):
How shall we format this string to include all the components? Perhaps:
_("local changed %s which remote deleted\n"
"use (c)changed version or (d)elete?"
"\f&Changed"
"\f&Delete")
I think something like \f or \b (not \t) will work well as a separator
but I have no idea if our l10n tools will agree with me. A quick test:
diff -r 0ec31231afad mercurial/merge.py
--- a/mercurial/merge.py Fri May 17 17:22:08 2013 -0500
+++ b/mercurial/merge.py Tue May 21 10:37:41 2013 -0500
@@ -365,8 +365,8 @@
actions.append((f, "r", None, "remote delete"))
elif repo.ui.promptchoice(
_("local changed %s which remote deleted\n"
- "use (c)hanged version or (d)elete?") % f,
- (_("&Changed"), _("&Delete")), 0):
+ "use (c)hanged version or (d)elete?"
+ "\f&Changed\f&Deleted") % f, 0):
actions.append((f, "r", None, "prompt delete"))
else:
actions.append((f, "a", None, "prompt keep"))
@@ -375,8 +375,8 @@
actions.append((f, "g", (m2.flags(f),), "remote recreating"))
elif repo.ui.promptchoice(
_("remote changed %s which local deleted\n"
- "use (c)hanged version or leave (d)eleted?") % f,
- (_("&Changed"), _("&Deleted")), 0) == 0:
+ "use (c)hanged version or leave (d)eleted?",
+ "\f&Changed\f&Deleted") % f, 0) == 0:
actions.append((f, "g", (m2.flags(f),), "prompt recreating"))
else: assert False, m
return actions
diff -r 0ec31231afad mercurial/ui.py
--- a/mercurial/ui.py Fri May 17 17:22:08 2013 -0500
+++ b/mercurial/ui.py Tue May 21 10:37:41 2013 -0500
@@ -639,13 +639,16 @@
except EOFError:
raise util.Abort(_('response expected'))
- def promptchoice(self, msg, choices, default=0):
+ def promptchoice(self, msg, choices=None, default=0):
"""Prompt user with msg, read response, and ensure it matches
one of the provided choices. The index of the choice is returned.
choices is a sequence of acceptable responses with the format:
('&None', 'E&xec', 'Sym&link') Responses are case insensitive.
If ui is not interactive, the default is returned.
"""
+ parts = msg.split('\f')
+ if len(parts):
+ msg, choices, default = parts[0], parts[1:], choices
resps = [s[s.index('&') + 1].lower() for s in choices]
while True:
r = self.prompt(msg, resps[default])
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list