[PATCH 1 of 2 STABLE] namespace: introduce logfmt to show l10n-ed messages for hg log correctly

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Jan 28 23:39:22 CST 2015


At Wed, 28 Jan 2015 10:23:46 -0800,
Sean Farley wrote:
> 
> 
> FUJIWARA Katsunori writes:
> 
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> > # Date 1422451379 -32400
> > #      Wed Jan 28 22:22:59 2015 +0900
> > # Branch stable
> > # Node ID 3da525e1db16adbc32734aa86a20cc7254724eb3
> > # Parent  1f3b94e8dc4012051482f54b51a07ff66e15dee2
> > namespace: introduce logfmt to show l10n-ed messages for hg log correctly
> >
> > Before this patch, "_()" is used incorrectly for "tag:" and
> > "bookmark:" fields. "changeset_printer()" looks up keys composed at
> > runtime, and it prevents "xgettext" command from getting strings to be
> > translated from source files.
> >
> > Then, *.po files merged with updated "hg.pot" lose msgids for "tag:"
> > and "bookmark:".
> >
> > This patch introduces "logfmt" information into "namespace" to show
> > l10n-ed messages "hg log" (or "changeset_printer()") correctly.
> >
> > For similarity to other namespaces, this patch specifies "logfmt" for
> > "branches" namespace, even though it isn't needed (branch information
> > is handled in "changeset_printer()" specially).
> >
> > To find related code paths out easily, this patch adds "i18n: column
> > positioning ..."  comment to the line composing "logfmt" by default,
> > even though this line itself doesn't contain any strings to be
> > translated.
> >
> > diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py
> > +++ b/mercurial/cmdutil.py
> > @@ -919,9 +919,8 @@ class changeset_printer(object):
> >              # we will use the templatename as the color name since those two
> >              # should be the same
> >              for name in ns.names(self.repo, changenode):
> > -                # i18n: column positioning for "hg log"
> > -                name = _(("%s:" % ns.logname).ljust(13) + "%s\n") % name
> > -                self.ui.write("%s" % name, label='log.%s' % ns.colorname)
> > +                self.ui.write(_(ns.logfmt) % name,
> > +                              label='log.%s' % ns.colorname)
> 
> Something I missed the first time around, isn't this double translating
> ns.logfmt?

Oops, you are right ! Thank you for checking deeply !

> >          if self.ui.debugflag:
> >              # i18n: column positioning for "hg log"
> >              self.ui.write(_("phase:       %s\n") % _(ctx.phasestr()),
> > diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py
> > --- a/mercurial/namespaces.py
> > +++ b/mercurial/namespaces.py
> > @@ -27,21 +27,30 @@ class namespaces(object):
> >          bmknames = lambda repo: repo._bookmarks.keys()
> >          bmknamemap = lambda repo, name: tolist(repo._bookmarks.get(name))
> >          bmknodemap = lambda repo, name: repo.nodebookmarks(name)
> > -        n = namespace("bookmarks", templatename="bookmark", listnames=bmknames,
> > +        n = namespace("bookmarks", templatename="bookmark",
> > +                      # i18n: column positioning for "hg log"
> > +                      logfmt=_("bookmark:    %s\n"),
> > +                      listnames=bmknames,
> 
> logfmt=_("bookmark:    %s\n") but above it's _(ns.logfmt)?
> 

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list