[PATCH 2 of 6] i18n: mark help strings for translation

Martin Geisler mg at daimi.au.dk
Fri Sep 5 18:11:18 CDT 2008


# HG changeset patch
# User Martin Geisler <mg at daimi.au.dk>
# Date 1220648780 -7200
# Node ID 116387a8ddd935c6e4028e53813351fc0358d431
# Parent  6e27b148d38efe47576d0f4627da8fc2f6691fe3
i18n: mark help strings for translation

The gettext function is just another name for the normal _ function
and it is used for translating docstrings when using _ would make
pygettext.py output a warning.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -7,7 +7,7 @@
 
 from node import hex, nullid, nullrev, short
 from repo import RepoError, NoCapability
-from i18n import _
+from i18n import _, gettext
 import os, re, sys, urllib
 import hg, util, revlog, bundlerepo, extensions, copies
 import difflib, patch, time, help, mdiff, tempfile
@@ -1282,7 +1282,7 @@
             ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
 
         # description
-        doc = i[0].__doc__
+        doc = gettext(i[0].__doc__)
         if not doc:
             doc = _("(No help text available)")
         if ui.quiet:
@@ -1308,7 +1308,7 @@
             f = f.lstrip("^")
             if not ui.debugflag and f.startswith("debug"):
                 continue
-            doc = e[0].__doc__
+            doc = gettext(e[0].__doc__)
             if not doc:
                 doc = _("(No help text available)")
             h[f] = doc.splitlines(0)[0].rstrip()
@@ -1355,7 +1355,8 @@
         except KeyError:
             raise cmdutil.UnknownCommand(name)
 
-        doc = (mod.__doc__ or _('No help text available')).splitlines(0)
+        doc = gettext(mod.__doc__) or _('No help text available')
+        doc = doc.splitlines(0)
         ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0]))
         for d in doc[1:]:
             ui.write(d, '\n')
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -5,9 +5,11 @@
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
+from i18n import _
+
 helptable = (
-    (["dates"], "Date Formats",
-    r'''
+    (["dates"], _("Date Formats"),
+     _(r'''
     Some commands allow the user to specify a date:
     backout, commit, import, tag: Specify the commit date.
     log, revert, update: Select revision(s) by date.
@@ -43,10 +45,10 @@
     ">{date}" - on or after a given date
     "{date} to {date}" - a date range, inclusive
     "-{days}" - within a given number of days of today
-    '''),
+    ''')),
 
-    (["patterns"], "File Name Patterns",
-    r'''
+    (["patterns"], _("File Name Patterns"),
+     _(r'''
     Mercurial accepts several notations for identifying one or more
     files at a time.
 
@@ -89,10 +91,10 @@
 
     re:.*\.c$      any name ending in ".c", anywhere in the repository
 
-    '''),
+    ''')),
 
-    (['environment', 'env'], 'Environment Variables',
-    r'''
+    (['environment', 'env'], _('Environment Variables'),
+     _(r'''
 HG::
     Path to the 'hg' executable, automatically passed when running hooks,
     extensions or external tools. If unset or empty, an executable named
@@ -160,10 +162,10 @@
 PYTHONPATH::
     This is used by Python to find imported modules and may need to be set
     appropriately if Mercurial is not installed system-wide.
-    '''),
+    ''')),
 
-    (['revs', 'revisions'], 'Specifying Single Revisions',
-    r'''
+    (['revs', 'revisions'], _('Specifying Single Revisions'),
+     _(r'''
     Mercurial accepts several notations for identifying individual
     revisions.
 
@@ -193,10 +195,10 @@
     no working directory is checked out, it is equivalent to null.
     If an uncommitted merge is in progress, "." is the revision of
     the first parent.
-    '''),
+    ''')),
 
-    (['mrevs', 'multirevs'], 'Specifying Multiple Revisions',
-    r'''
+    (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'),
+     _(r'''
     When Mercurial accepts more than one revision, they may be
     specified individually, or provided as a continuous range,
     separated by the ":" character.
@@ -212,5 +214,5 @@
 
     A range acts as a closed interval. This means that a range of 3:5
     gives 3, 4 and 5. Similarly, a range of 4:2 gives 4, 3, and 2.
-    '''),
+    ''')),
 )


More information about the Mercurial-devel mailing list