# HG changeset patch # User Patrick Mezard # Date 1287917557 -7200 # Node ID 80deae3bc5ea74a160c79788e8064a3db0235b98 # Parent f13acb96b2a73bf3603fb5b664cd16e6364bcc1f hggettext: handle i18nfunctions declaration for docstrings translations diff -r f13acb96b2a7 -r 80deae3bc5ea hgext/bookmarks.py --- a/hgext/bookmarks.py Sat Oct 23 19:22:42 2010 +0200 +++ b/hgext/bookmarks.py Sun Oct 24 12:52:37 2010 +0200 @@ -566,3 +566,6 @@ } colortable = {'bookmarks.current': 'green'} + +# tell hggettext to extract docstrings from these functions: +i18nfunctions = [bmrevset] diff -r f13acb96b2a7 -r 80deae3bc5ea hgext/transplant.py --- a/hgext/transplant.py Sat Oct 23 19:22:42 2010 +0200 +++ b/hgext/transplant.py Sun Oct 24 12:52:37 2010 +0200 @@ -625,3 +625,6 @@ _('hg transplant [-s REPO] [-b BRANCH [-a]] [-p REV] ' '[-m REV] [REV]...')) } + +# tell hggettext to extract docstrings from these functions: +i18nfunctions = [revsettransplanted] diff -r f13acb96b2a7 -r 80deae3bc5ea i18n/hggettext --- a/i18n/hggettext Sat Oct 23 19:22:42 2010 +0200 +++ b/i18n/hggettext Sun Oct 24 12:52:37 2010 +0200 @@ -97,19 +97,25 @@ lineno = 1 + offset(src, mod.__doc__, path, 7) print poentry(path, lineno, mod.__doc__) + functions = list(getattr(mod, 'i18nfunctions', [])) + functions = [(f, True) for f in functions] + cmdtable = getattr(mod, 'cmdtable', {}) if not cmdtable: # Maybe we are processing mercurial.commands? cmdtable = getattr(mod, 'table', {}) + functions.extend((c[0], False) for c in cmdtable.itervalues()) - for entry in cmdtable.itervalues(): - func = entry[0] + for func, rstrip in functions: if func.__doc__: src = inspect.getsource(func) name = "%s.%s" % (path, func.__name__) lineno = func.func_code.co_firstlineno - lineno += offset(src, func.__doc__, name, 1) - print poentry(path, lineno, func.__doc__) + doc = func.__doc__ + if rstrip: + doc = doc.rstrip() + lineno += offset(src, doc, name, 1) + print poentry(path, lineno, doc) def rawtext(path): diff -r f13acb96b2a7 -r 80deae3bc5ea mercurial/revset.py --- a/mercurial/revset.py Sat Oct 23 19:22:42 2010 +0200 +++ b/mercurial/revset.py Sun Oct 24 12:52:37 2010 +0200 @@ -791,3 +791,6 @@ predicates = '\n'.join(predicates) doc = doc.replace('.. predicatesmarker', predicates) return doc + +# tell hggettext to extract docstrings from these functions: +i18nfunctions = symbols.values()