log: translate column labels at once (
issue5750)
This makes sure that all columns are aligned. getlogcolumns() is hosted by
templatekw so the namespaces module can see it.
i18n/de.po is updated so test-log.t passes with no error. "obsolete:" and
"instability:" are kept untranslated.
--- a/i18n/de.po Sat Dec 02 16:08:24 2017 +0900
+++ b/i18n/de.po Sat Dec 02 16:29:49 2017 +0900
@@ -9744,86 +9744,9 @@
msgid "child process failed to start"
msgstr ""
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "changeset: %s\n"
-msgstr "Änderung: %s\n"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "branch: %s\n"
-msgstr "Zweig: %s\n"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "bookmark: %s\n"
-msgstr "Lesezeichen: %s\n"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "tag: %s\n"
-msgstr "Marke: %s\n"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "phase: %s\n"
-msgstr "Phase: %s\n"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "parent: %s\n"
-msgstr "Vorgänger: %s\n"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "manifest: %d:%s\n"
-msgstr "Manifest: %d:%s\n"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "user: %s\n"
-msgstr "Nutzer: %s\n"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "date: %s\n"
-msgstr "Datum: %s\n"
-
-#. i18n: column positioning for "hg log"
-msgid "files:"
-msgstr "Dateien:"
-
-#. i18n: column positioning for "hg log"
-msgid "files+:"
-msgstr "Dateien+:"
-
-#. i18n: column positioning for "hg log"
-msgid "files-:"
-msgstr "Dateien-:"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "files: %s\n"
-msgstr "Dateien: %s\n"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "copies: %s\n"
-msgstr "Kopien: %s\n"
-
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "extra: %s=%s\n"
-msgstr "Extra: %s=%s\n"
-
msgid "description:\n"
msgstr "Beschreibung:\n"
-#. i18n: column positioning for "hg log"
-#, python-format
-msgid "summary: %s\n"
-msgstr "Zusammenfassung: %s\n"
-
#, python-format
msgid "%s: no key named '%s'"
msgstr "%s: kein Schlüsselwort '%s'"
@@ -23194,6 +23117,45 @@
":emailuser: Beliebiger Text. Gibt den Nutzerteil einer E-Mail-Adresse\n"
" (vor dem @-Zeichen) zurück."
+#. i18n: column positioning for "hg log"
+#, python-format
+msgid ""
+"bookmark: %s\n"
+"branch: %s\n"
+"changeset: %s\n"
+"copies: %s\n"
+"date: %s\n"
+"extra: %s=%s\n"
+"files+: %s\n"
+"files-: %s\n"
+"files: %s\n"
+"instability: %s\n"
+"manifest: %s\n"
+"obsolete: %s\n"
+"parent: %s\n"
+"phase: %s\n"
+"summary: %s\n"
+"tag: %s\n"
+"user: %s\n"
+msgstr ""
+"Lesezeichen: %s\n"
+"Zweig: %s\n"
+"Änderung: %s\n"
+"Kopien: %s\n"
+"Datum: %s\n"
+"Extra: %s=%s\n"
+"Dateien+: %s\n"
+"Dateien-: %s\n"
+"Dateien: %s\n"
+"instability: %s\n"
+"Manifest: %s\n"
+"obsolete: %s\n"
+"Vorgänger: %s\n"
+"Phase: %s\n"
+"Zusammenfassung: %s\n"
+"Marke: %s\n"
+"Nutzer: %s\n"
+
msgid ":author: String. The unmodified author of the changeset."
msgstr ":author: Zeichenkette. Der unveränderte Autor eines Änderungssatzes."
--- a/mercurial/cmdutil.py Sat Dec 02 16:08:24 2017 +0900
+++ b/mercurial/cmdutil.py Sat Dec 02 16:29:49 2017 +0900
@@ -1571,6 +1571,7 @@
self.hunk = {}
self.lastheader = None
self.footer = None
+ self._columns = templatekw.getlogcolumns()
def flush(self, ctx):
rev = ctx.rev()
@@ -1610,8 +1611,8 @@
label='log.node')
return
- # i18n: column positioning for "hg log"
- self.ui.write(_("changeset: %s\n") % scmutil.formatchangeid(ctx),
+ columns = self._columns
+ self.ui.write(columns['changeset'] % scmutil.formatchangeid(ctx),
label=_changesetlabels(ctx))
# branches are shown first before any other names due to backwards
@@ -1619,9 +1620,7 @@
branch = ctx.branch()
# don't show the default branch name
if branch != 'default':
- # i18n: column positioning for "hg log"
- self.ui.write(_("branch: %s\n") % branch,
- label='log.branch')
+ self.ui.write(columns['branch'] % branch, label='log.branch')
for nsname, ns in self.repo.names.iteritems():
# branches has special logic already handled above, so here we just
@@ -1634,33 +1633,25 @@
self.ui.write(ns.logfmt % name,
label='log.%s' % ns.colorname)
if self.ui.debugflag:
- # i18n: column positioning for "hg log"
- self.ui.write(_("phase: %s\n") % ctx.phasestr(),
- label='log.phase')
+ self.ui.write(columns['phase'] % ctx.phasestr(), label='log.phase')
for pctx in scmutil.meaningfulparents(self.repo, ctx):
label = 'log.parent changeset.%s' % pctx.phasestr()
- # i18n: column positioning for "hg log"
- self.ui.write(_("parent: %s\n") % scmutil.formatchangeid(pctx),
+ self.ui.write(columns['parent'] % scmutil.formatchangeid(pctx),
label=label)
if self.ui.debugflag and rev is not None:
mnode = ctx.manifestnode()
mrev = self.repo.manifestlog._revlog.rev(mnode)
- # i18n: column positioning for "hg log"
- self.ui.write(_("manifest: %s\n")
+ self.ui.write(columns['manifest']
% scmutil.formatrevnode(self.ui, mrev, mnode),
label='ui.debug log.manifest')
- # i18n: column positioning for "hg log"
- self.ui.write(_("user: %s\n") % ctx.user(),
- label='log.user')
- # i18n: column positioning for "hg log"
- self.ui.write(_("date: %s\n") % util.datestr(ctx.date()),
+ self.ui.write(columns['user'] % ctx.user(), label='log.user')
+ self.ui.write(columns['date'] % util.datestr(ctx.date()),
label='log.date')
if ctx.isunstable():
- # i18n: column positioning for "hg log"
instabilities = ctx.instabilities()
- self.ui.write(_("instability: %s\n") % ', '.join(instabilities),
+ self.ui.write(columns['instability'] % ', '.join(instabilities),
label='log.instability')
elif ctx.obsolete():
@@ -1670,31 +1661,22 @@
if self.ui.debugflag:
files = ctx.p1().status(ctx)[:3]
- for key, value in zip([# i18n: column positioning for "hg log"
- _("files:"),
- # i18n: column positioning for "hg log"
- _("files+:"),
- # i18n: column positioning for "hg log"
- _("files-:")], files):
+ for key, value in zip(['files', 'files+', 'files-'], files):
if value:
- self.ui.write("%-12s %s\n" % (key, " ".join(value)),
+ self.ui.write(columns[key] % " ".join(value),
label='ui.debug log.files')
elif ctx.files() and self.ui.verbose:
- # i18n: column positioning for "hg log"
- self.ui.write(_("files: %s\n") % " ".join(ctx.files()),
+ self.ui.write(columns['files'] % " ".join(ctx.files()),
label='ui.note log.files')
if copies and self.ui.verbose:
copies = ['%s (%s)' % c for c in copies]
- # i18n: column positioning for "hg log"
- self.ui.write(_("copies: %s\n") % ' '.join(copies),
+ self.ui.write(columns['copies'] % ' '.join(copies),
label='ui.note log.copies')
extra = ctx.extra()
if extra and self.ui.debugflag:
for key, value in sorted(extra.items()):
- # i18n: column positioning for "hg log"
- self.ui.write(_("extra: %s=%s\n")
- % (key, util.escapestr(value)),
+ self.ui.write(columns['extra'] % (key, util.escapestr(value)),
label='ui.debug log.extra')
description = ctx.description().strip()
@@ -1706,9 +1688,7 @@
label='ui.note log.description')
self.ui.write("\n\n")
else:
- # i18n: column positioning for "hg log"
- self.ui.write(_("summary: %s\n") %
- description.splitlines()[0],
+ self.ui.write(columns['summary'] % description.splitlines()[0],
label='log.summary')
self.ui.write("\n")
@@ -1719,8 +1699,7 @@
if obsfate:
for obsfateline in obsfate:
- # i18n: column positioning for "hg log"
- self.ui.write(_("obsolete: %s\n") % obsfateline,
+ self.ui.write(self._columns['obsolete'] % obsfateline,
label='log.obsfate')
def _exthook(self, ctx):
--- a/mercurial/namespaces.py Sat Dec 02 16:08:24 2017 +0900
+++ b/mercurial/namespaces.py Sat Dec 02 16:29:49 2017 +0900
@@ -25,6 +25,7 @@
def __init__(self):
self._names = util.sortdict()
+ columns = templatekw.getlogcolumns()
# we need current mercurial named objects (bookmarks, tags, and
# branches) to be initialized somewhere, so that place is here
@@ -32,8 +33,7 @@
bmknamemap = lambda repo, name: tolist(repo._bookmarks.get(name))
bmknodemap = lambda repo, node: repo.nodebookmarks(node)
n = namespace("bookmarks", templatename="bookmark",
- # i18n: column positioning for "hg log"
- logfmt=_("bookmark: %s\n"),
+ logfmt=columns['bookmark'],
listnames=bmknames,
namemap=bmknamemap, nodemap=bmknodemap,
builtin=True)
@@ -43,8 +43,7 @@
tagnamemap = lambda repo, name: tolist(repo._tagscache.tags.get(name))
tagnodemap = lambda repo, node: repo.nodetags(node)
n = namespace("tags", templatename="tag",
- # i18n: column positioning for "hg log"
- logfmt=_("tag: %s\n"),
+ logfmt=columns['tag'],
listnames=tagnames,
namemap=tagnamemap, nodemap=tagnodemap,
deprecated={'tip'},
@@ -55,8 +54,7 @@
bnamemap = lambda repo, name: tolist(repo.branchtip(name, True))
bnodemap = lambda repo, node: [repo[node].branch()]
n = namespace("branches", templatename="branch",
- # i18n: column positioning for "hg log"
- logfmt=_("branch: %s\n"),
+ logfmt=columns['branch'],
listnames=bnames,
namemap=bnamemap, nodemap=bnodemap,
builtin=True)
--- a/mercurial/templatekw.py Sat Dec 02 16:08:24 2017 +0900
+++ b/mercurial/templatekw.py Sat Dec 02 16:29:49 2017 +0900
@@ -17,6 +17,7 @@
encoding,
error,
hbisect,
+ i18n,
obsutil,
patch,
pycompat,
@@ -301,6 +302,30 @@
return getrenamed
+def getlogcolumns():
+ """Return a dict of log column labels"""
+ _ = pycompat.identity # temporarily disable gettext
+ # i18n: column positioning for "hg log"
+ columns = _('bookmark: %s\n'
+ 'branch: %s\n'
+ 'changeset: %s\n'
+ 'copies: %s\n'
+ 'date: %s\n'
+ 'extra: %s=%s\n'
+ 'files+: %s\n'
+ 'files-: %s\n'
+ 'files: %s\n'
+ 'instability: %s\n'
+ 'manifest: %s\n'
+ 'obsolete: %s\n'
+ 'parent: %s\n'
+ 'phase: %s\n'
+ 'summary: %s\n'
+ 'tag: %s\n'
+ 'user: %s\n')
+ return dict(zip([s.split(':', 1)[0] for s in columns.splitlines()],
+ i18n._(columns).splitlines(True)))
+
# default templates internally used for rendering of lists
defaulttempl = {
'parent': '{rev}:{node|formatnode} ',