Commit Graph

13 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
3880aa6258 i18n: ignore docstring for modules under mercurial
Docstring of modules is needed only for "hg help -e EXTNAME".

This is a preparation for applying hggettext on util.py, which has
module docstring, but it isn't needed for translation.
2017-08-15 21:06:26 +09:00
FUJIWARA Katsunori
cabc81b3e9 i18n: use saved object to get actual function information if available
To list up available compression types instead of
".. bundlecompressionmarker" in "hg help bundlespec" output, proxy
object "docobject" is used, because:

- current online help system requires that __doc__ of registered
  object (maybe, function) is already well formatted in reST syntax

- bundletype() method of compressionengine classes is used to list up
  available compression types, but

- __doc__ of bundletype() object (= "instancemethod") is read-only

On the other hand, hggettext requires original function object, in
order to get document location in source code.

Therefore, description of each compression types isn't yet
translatable. Even if translatable, translators should make much
effort to determine location of original texts in source code.

To get actual function information, this patch makes hggettext use
function object saved as "_origfunc", if it is available. This patch
also changes bundlecompressiontopics() side, in order to explain how
these changes work easily.

This patch is a part of preparations for making description of each
compression types translatable.
2017-08-15 19:27:24 +09:00
FUJIWARA Katsunori
c9b96a17fc i18n: ignore doctest part to avoid warning at "make update-pot"
hggettext assumes that backslashes in docstring are always doubled in
original source code, in order to find the location of original
docstring out certainly.

This assumption almost always works as expected. But doctest easily
breaks it, because many of backslashes in doctests aren't doubled.
This mismatching causes "unknown offset in ..." warning at "make
update-pot".

To avoid such warning, this patch ignores doctest part of docstring
before finding the location of original docstring out.

BTW, at this patch, only person() in templatefilters.py has doctest
part, which causes "unknown offset ..." warning.

Therefore, just making backslashes in that doctest doubled can avoid
such warning, too. But forcing doctest writers to double backslashes
in doctest isn't reasonable, IMHO.
2017-08-13 15:20:16 +09:00
FUJIWARA Katsunori
e62afbdb39 i18n: make hggettext use original docstring to compute offset
Before this patch, hggettext uses __doc__ of each functions to compute
offset of document text.

But __doc__ of many functions is already modified by decorators in
registrar (e.g. @templatekeyword adds ":NAME: " prefix to it), and
hggettext can not find it out in original source.

This causes many "unknown offset in ..." warning at "make update-pot",
and leaving them might cause overlooking serious problems.

This patch makes hggettext use original docstring, which decorators in
registrar save into _origdoc, to compute offset.

Even after this patch, there are still a few "unknown offset in ..."
warning at "make update-pot" for specific reasons. These will be fixed
later one by one.
2017-08-02 01:03:20 +09:00
FUJIWARA Katsunori
cfbdc0a924 i18n: use actual filename, in which function is defined, for hg.pot
Before this patch, source filename for msgid in hg.pot file becomes
incorrect, if a function is defined in file A, but detected in dict in
file B,

For example, almost all debug* commands are defined in
debugcommands.py, but hggettext detects them in "table" of
commands.py. Therefore, docstring fragments of debug* commands are
marked as "defined in commands.py" in hg.pot file.

This is serious problem for translation, because the cost to find out
original location of texts increases very much.
2017-08-02 00:02:11 +09:00
Yuya Nishihara
146f5e3a27 i18n: use inspect.getsourcelines() to obtain lineno from func or class
Before, func must be a function object. I want to make it parse docstring
of classes, too.
2016-07-27 21:53:14 +09:00
Pulkit Goyal
ce56f5973f py3: make i18n/hggettext use print_function 2016-05-13 02:58:15 +05:30
Pulkit Goyal
f24edb8c72 py3: make i18n/hggettext use absolute_import 2016-05-13 02:56:13 +05:30
Patrick Mezard
3fd83b5b68 hggettext: handle i18nfunctions declaration for docstrings translations 2010-10-24 12:52:37 +02:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Martin Geisler
524b665b54 help: move help topics from mercurial/help.py to help/*.txt
The help topics are loaded on demand so we wont hit the disk unless we
really have to.
2009-10-04 09:59:13 +02:00
Martin Geisler
cb2e1d2019 hggettext: ensure correct Mercurial is imported 2009-05-26 20:12:37 +02:00
Martin Geisler
b205b95666 i18n: accurately generate hg.pot 2009-05-21 23:43:13 +02:00