Fix gettext call

Marcos Chaves marcos.nospam at gmail.com
Sat Nov 18 14:57:11 CST 2006


Thomas and Matt,

I have no idea why I thought only that file had gettext calls...
anyway, following is the patch that makes pygettext.py happy if I run:

find . -name "*.py" | xargs pygettext.py

Well... almost happy. It still complains about this piece of code in
contrib/purge/purge.py:

def _(s):
    return s

But this one looks like a stub for gettext, while it's not used. If
so, than I think we can just leave it there.

I found this problem when using Windows' pygettext.py. But, if someone
needs it, this is how I created the translation template on Linux,
just to see if was good:

find . -name "*.py" | xgettext --sort-by-file --files-from=-

I hope this is useful.

-Marcos

Obs.: patch goes attached too, in case my mailer breaks the lines.

# HG changeset patch
# User Marcos Chaves <marcos.nospam at gmail.com>
# Date 1163877638 7200
# Node ID b388fdc1aa1da6dbd39fb5933aebdaa7eca33478
# Parent  9103dab960932c5b1337dc6dad361437ce9a84e9
fix warnings generated by pygettext.py.

diff -r 9103dab96093 -r b388fdc1aa1d hgext/notify.py
--- a/hgext/notify.py	Sat Nov 18 11:34:19 2006 -0600
+++ b/hgext/notify.py	Sat Nov 18 17:20:38 2006 -0200
@@ -259,7 +259,7 @@ def hook(ui, repo, hooktype, node=None,
     changegroup. else send one email per changeset.'''
     n = notifier(ui, repo, hooktype)
     if not n.subs:
-        ui.debug(_('notify: no subscribers to repo %s\n' % n.root))
+        ui.debug(_('notify: no subscribers to repo %s\n') % n.root)
         return
     if n.skipsource(source):
         ui.debug(_('notify: changes have source "%s" - skipping\n') %
diff -r 9103dab96093 -r b388fdc1aa1d mercurial/commands.py
--- a/mercurial/commands.py	Sat Nov 18 11:34:19 2006 -0600
+++ b/mercurial/commands.py	Sat Nov 18 17:20:38 2006 -0200
@@ -213,8 +213,8 @@ def backout(ui, repo, rev, **opts):
                                '--parent'))
         p = repo.lookup(opts['parent'])
         if p not in (p1, p2):
-            raise util.Abort(_('%s is not a parent of %s' %
-                               (short(p), short(node))))
+            raise util.Abort(_('%s is not a parent of %s') %
+                               (short(p), short(node)))
         parent = p
     else:
         if opts['parent']:
@@ -1969,12 +1969,12 @@ def revert(ui, repo, *pats, **opts):
             elif misslist is not None:
                 handle(misslist, backupmiss)
             else:
-                if exact: ui.warn(_('file not managed: %s\n' % rel))
+                if exact: ui.warn(_('file not managed: %s\n') % rel)
             break
         else:
             # file has not changed in dirstate
             if node == parent:
-                if exact: ui.warn(_('no changes needed to %s\n' % rel))
+                if exact: ui.warn(_('no changes needed to %s\n') % rel)
                 continue
             if pmf is None:
                 # only need parent manifest in this unlikely case,
diff -r 9103dab96093 -r b388fdc1aa1d mercurial/hg.py
--- a/mercurial/hg.py	Sat Nov 18 11:34:19 2006 -0600
+++ b/mercurial/hg.py	Sat Nov 18 17:20:38 2006 -0200
@@ -242,8 +242,8 @@ def merge(repo, node, force=None, remind
         repo.ui.status(_("There are unresolved merges,"
                          " you can redo the full merge using:\n"
                          "  hg update -C %s\n"
-                         "  hg merge %s\n"
-                         % (pl[0].rev(), pl[1].rev())))
+                         "  hg merge %s\n")
+                         % (pl[0].rev(), pl[1].rev()))
     elif remind:
         repo.ui.status(_("(branch merge, don't forget to commit)\n"))
     return stats[3]
diff -r 9103dab96093 -r b388fdc1aa1d mercurial/revlog.py
--- a/mercurial/revlog.py	Sat Nov 18 11:34:19 2006 -0600
+++ b/mercurial/revlog.py	Sat Nov 18 17:20:38 2006 -0200
@@ -30,7 +30,7 @@ def flagstr(flag):
 def flagstr(flag):
     if flag == "inline":
         return REVLOGNGINLINEDATA
-    raise RevlogError(_("unknown revlog flag %s" % flag))
+    raise RevlogError(_("unknown revlog flag %s") % flag)

 def hash(text, p1, p2):
     """generate a hash from the given text and its parent hashes
@@ -355,15 +355,15 @@ class revlog(object):
         fmt = v & 0xFFFF
         if fmt == REVLOGV0:
             if flags:
-                raise RevlogError(_("index %s invalid flags %x for format v0" %
-                                   (self.indexfile, flags)))
+                raise RevlogError(_("index %s invalid flags %x for
format v0") %
+                                   (self.indexfile, flags))
         elif fmt == REVLOGNG:
             if flags & ~REVLOGNGINLINEDATA:
-                raise RevlogError(_("index %s invalid flags %x for revlogng" %
-                                   (self.indexfile, flags)))
-        else:
-            raise RevlogError(_("index %s invalid format %d" %
-                               (self.indexfile, fmt)))
+                raise RevlogError(_("index %s invalid flags %x for revlogng") %
+                                   (self.indexfile, flags))
+        else:
+            raise RevlogError(_("index %s invalid format %d") %
+                               (self.indexfile, fmt))
         self.version = v
         if v == REVLOGV0:
             self.indexformat = indexformatv0
@@ -931,8 +931,8 @@ class revlog(object):
             return
         trinfo = tr.find(self.indexfile)
         if trinfo == None:
-            raise RevlogError(_("%s not found in the transaction"  %
-                              self.indexfile))
+            raise RevlogError(_("%s not found in the transaction")  %
+                              self.indexfile)

         trindex = trinfo[2]
         dataoff = self.start(trindex)


On 11/18/06, Thomas Arendsen Hein <thomas at intevation.de> wrote:
> * Marcos Chaves <marcos.nospam at gmail.com> [20061118 20:09]:
> > I read that i18n support is planned for the future, so I run
> > pygettext.py on mercurial/commands.py (seems to be the only file with
> > _() calls) just to see if it worked and noticed that there were 3
> > gettext calls that don't seem to be properly formatted, generating
> > warnings. Attached is a simple patch that fixes them, so pygettext.py
> > runs with no errors and all messages are properly extracted.
>
> Your patch looks good, but can you check if the other files needs
> fixing, too? And then please commit it locally and use 'hg export',
> so we can simply import it and you automatically get all the credits
> for it :)
>
> Thomas
>
> --
> Email: thomas at intevation.de
> http://intevation.de/~thomas/
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-gettext.patch
Type: application/octet-stream
Size: 4936 bytes
Desc: not available
Url : http://www.selenic.com/pipermail/mercurial-devel/attachments/20061118/05df1aec/fix-gettext-0001.obj


More information about the Mercurial-devel mailing list