Merged in kenhys/sphinx (pull request #217)

Add feature to suppress uuid/location information for message catalogs
This commit is contained in:
Georg Brandl 2014-03-01 08:21:59 +01:00
commit d50c5efb1a
3 changed files with 23 additions and 7 deletions

View File

@ -399,6 +399,19 @@ documentation on :ref:`intl` for details.
By default, the document ``markup/code.rst`` ends up in the ``markup`` text
domain. With this option set to ``False``, it is ``markup/code``.
.. confval:: gettext_uuid
If true, ``sphinx`` generates message catalogs with uuid information
for ``pot`` files. If false, ``sphinx`` doesn't do it.
The default is ``true``.
.. confval:: gettext_location
If true, ``sphinx`` generates message catalogs with location information
for ``pot`` files. If false, ``sphinx`` doesn't do it.
The default is ``true``.
.. _html-options:

View File

@ -196,13 +196,14 @@ class MessageCatalogBuilder(I18nBuilder):
for message in catalog.messages:
positions = catalog.metadata[message]
# generate "#: file1:line1\n#: file2:line2 ..."
pofile.write(u"#: %s\n" % "\n#: ".join("%s:%s" %
(safe_relpath(source, self.outdir), line)
for source, line, _ in positions))
# generate "# uuid1\n# uuid2\n ..."
pofile.write(u"# %s\n" % "\n# ".join(uid for _, _, uid
in positions))
if self.config.gettext_location:
# generate "#: file1:line1\n#: file2:line2 ..."
pofile.write(u"#: %s\n" % "\n#: ".join("%s:%s" %
(safe_relpath(source, self.outdir), line)
for source, line, _ in positions))
if self.config.gettext_uuid:
# generate "# uuid1\n# uuid2\n ..."
pofile.write(u"# %s\n" % "\n# ".join(uid for _, _, uid in positions))
# message contains *one* line of text ready for translation
message = message.replace(u'\\', ur'\\'). \

View File

@ -201,6 +201,8 @@ class Config(object):
# gettext options
gettext_compact = (True, 'gettext'),
gettext_location = (True, None),
gettext_uuid = (True, None),
# XML options
xml_pretty = (True, 'env'),