diff options
author | Vincent Férotin <vincent.ferotin@gmail.com> | 2019-01-28 17:48:50 +0300 |
---|---|---|
committer | Vincent Férotin <vincent.ferotin@gmail.com> | 2019-01-28 17:48:50 +0300 |
commit | 98fd02e262af4bc992d9727f2c1c73d62f51f31d (patch) | |
tree | 5a28a4ed343be0da5388b34de0ab610741f02b83 /sphinx/locale | |
parent | 97d99f830258a4612a6c77f5be084819634dcbad (diff) |
doc: Enhance documentation about internalization of external extension.
Diffstat (limited to 'sphinx/locale')
-rw-r--r-- | sphinx/locale/__init__.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py index e955e34f5..4c5481f0e 100644 --- a/sphinx/locale/__init__.py +++ b/sphinx/locale/__init__.py @@ -255,17 +255,18 @@ def get_translation(catalog, namespace='general'): import os from sphinx.locale import get_translation - _ = get_translation(__name__) + EXTENSION_NAME = 'myextension' # name of both *.pot, *.po and *.mo files + _ = get_translation(EXTENSION_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(EXTENSION_NAME, locale_dir) With this code, sphinx searches a message catalog from - ``${package_dir}/locales/${language}/LC_MESSAGES/${__name__}.mo`` + ``${package_dir}/locales/${language}/LC_MESSAGES/myextension.mo`` The :confval:`language` is used for the searching. .. versionadded:: 1.8 |