Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-03-09 19:16:06 +0300
committerGitHub <noreply@github.com>2019-03-09 19:16:06 +0300
commit2606002bb4d0470181460740b608d13d03b84bfe (patch)
tree3744d44300cd1306ef725b38e4023bc3d059e78b /sphinx/locale
parentfe48b9b5b725199273e6ab66ce7f7e9054cc5830 (diff)
parentb3b5a595a91c7afd4da7ae71e762756d638459dd (diff)
Merge pull request #6125 from tk0miya/doc-enhance_extension_dev_i18n
doc: Enhance documentation about internalization of external extension (refs: #5991)
Diffstat (limited to 'sphinx/locale')
-rw-r--r--sphinx/locale/__init__.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py
index 77566ec04..6ae20d0d0 100644
--- a/sphinx/locale/__init__.py
+++ b/sphinx/locale/__init__.py
@@ -255,20 +255,19 @@ def get_translation(catalog, namespace='general'):
import os
from sphinx.locale import get_translation
- _ = get_translation(__name__)
+ MESSAGE_CATALOG_NAME = 'myextension' # name of *.pot, *.po and *.mo files
+ _ = get_translation(MESSAGE_CATALOG_NAME)
text = _('Hello Sphinx!')
def setup(app):
package_dir = path.abspath(path.dirname(__file__))
locale_dir = os.path.join(package_dir, 'locales')
- app.add_message_catalog(__name__, locale_dir)
+ app.add_message_catalog(MESSAGE_CATALOG_NAME, locale_dir)
With this code, sphinx searches a message catalog from
- ``${package_dir}/locales/${language}/LC_MESSAGES/${__name__}.mo``
- (ex. ``sphinxcontrib.applehelp.mo``). Of course, you can use
- arbitrary catalog name instead of ``__name__``. The
- :confval:`language` is used for the searching.
+ ``${package_dir}/locales/${language}/LC_MESSAGES/myextension.mo``.
+ The :confval:`language` is used for the searching.
.. versionadded:: 1.8
"""