summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhayashi <hayashi@clear-code.com>2014-02-01 02:34:09 +0900
committerhayashi <hayashi@clear-code.com>2014-02-01 02:34:09 +0900
commit0b33a665e0880f0ccfe1707984440a8c98fd3987 (patch)
treed4ca0859d32d3d44ee253a783996fbe6f22aca19
parent4b0d09374e4c781cd991a0a1ff19547025e009b7 (diff)
downloadsphinx-0b33a665e0880f0ccfe1707984440a8c98fd3987.tar.gz
Add feature to suppress uuid/location information for message catalogs
Before: default #: ../../../source/news.txt:6 # 9f62de6b9c3b477095dba5e468972e6d msgid "News" msgstr After: suppress uuid & location information msgid "News" msgstr
-rw-r--r--doc/config.rst13
-rw-r--r--sphinx/builders/gettext.py15
-rw-r--r--sphinx/config.py2
3 files changed, 23 insertions, 7 deletions
diff --git a/doc/config.rst b/doc/config.rst
index 1b196abb..12165cf6 100644
--- a/doc/config.rst
+++ b/doc/config.rst
@@ -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:
diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py
index f11ac293..06bda7be 100644
--- a/sphinx/builders/gettext.py
+++ b/sphinx/builders/gettext.py
@@ -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'\\'). \
diff --git a/sphinx/config.py b/sphinx/config.py
index 127425ae..c1f91aec 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -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'),