[PATCH 3 of 3] record: display the running operation for recording commands

Matt Mackall mpm at selenic.com
Thu May 28 15:25:08 CDT 2015


On Wed, 2015-05-27 at 16:43 -0700, Laurent Charignon wrote:
>              resps = _('[Ynesfdaq?]'
> -                      '$$ &Yes, record this change'
> +                      '$$ &Yes, ' + operation + ' this change'

Yep, i18n headaches abound here. I just spotted these on pull, this is a
good example of where.

Generally the _(x) construct needs x to always be a string constant.
That's because a) x is extracted wholesale for localization by automated
tools, and b) x is looked up verbatim at runtime to retrieve the
translation.

So a couple things need to happen: 

- wherever we first introduce an operation name as a string literal (eg
"record"), it needs to be wrapped in _() at that point (only)
- we should assume that any operation name passed to us is thus already
translated
- if we need to do comparisons for some reason, we need to compare
against _("a literal")
- wherever we use operation for output, we need to do _("blah blah %s")
% operation, with the % outside the _() so it can look up a constant

If you're ever doing something like one of these:

  _("blah %s" % x)
  _("blah" + x)
  _(somevariablename)
  _("something").upper() # what is uppercase Japanese?
  len(_("something")) # len != characters != column width

..then something is almost certainly wrong.

However, I think this should all be fixable in another quick pass, so
I'm going to go ahead and drop all but the first one which introduces
the arg.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list