Mercurial > hg
diff i18n/hggettext @ 12823:80deae3bc5ea stable
hggettext: handle i18nfunctions declaration for docstrings translations
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sun, 24 Oct 2010 12:52:37 +0200 |
parents | 25e572394f5c |
children | 2516bba643e7 |
line wrap: on
line diff
--- 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):