-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Improve i18n #4674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve i18n #4674
Conversation
Updating _catalog attribute directly breaks a internal cache of gettext module.
| logger.debug('[app] adding HTML theme: %r, %r', name, theme_path) | ||
| self.html_themes[name] = theme_path | ||
|
|
||
| def add_message_catalog(self, catalog, locale_dir): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to add the autodoc entry to doc/extdev.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
sphinx/application.py
Outdated
| The *catalog* is a name of catalog, and *locale_dir* is a base path | ||
| of message catalog. For more details, see | ||
| :func:`sphinx.locales.get_translation()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not documented yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
|
||
| # A shortcut for sphinx-core | ||
| _ = get_translation('sphinx') | ||
| __ = get_translation('sphinx', 'console') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These helper function is also not documented. I know they are not "public". But they are important internal APIs. So documentation is useful for maintainers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| ``${package_dir}/locales/${language}/LC_MESSAGES/${__name__}.mo`` | ||
| The :confval:`language` is used for the searching. | ||
| .. versionadded:: 1.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I heard from @cocoatomo that python-doc uses very hacky way to translate messages on their extensions.
python/cpython#4473 (see dummy.html).
| 'deprecated': _('Deprecated since version %s'), | ||
| } # type: Dict[unicode, unicode] | ||
|
|
||
| # XXX Python specific |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll move these messages to specific modules in another PR.
|
Oh, tests are broken. I'll check it later. |
sphinx/locale/__init__.py
Outdated
| translator = translators.get((namespace, catalog)) | ||
| # ignore previously failed attempts to find message catalogs | ||
| if isinstance(translator, gettext.NullTranslations): | ||
| if isinstance(translator, NullTranslations): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this merging process does not work.
All translations object is a subclass of NullTranslations!
>>> import gettext
>>> isinstance(gettext.GNUTranslations(), gettext.NullTranslations)
True
7a854e2 to
17d7e46
Compare
Codecov Report
@@ Coverage Diff @@
## master #4674 +/- ##
==========================================
+ Coverage 81.35% 81.39% +0.04%
==========================================
Files 288 284 -4
Lines 37989 37722 -267
Branches 5911 5851 -60
==========================================
- Hits 30905 30705 -200
+ Misses 5634 5581 -53
+ Partials 1450 1436 -14
Continue to review full report at Codecov.
|
0188593 to
bc31485
Compare
8351f88 to
645ad75
Compare
Feature or Bugfix
Purpose
LC_*)l_()into_()sphinx.localemodule to do that.