🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@tk0miya
Copy link
Member

@tk0miya tk0miya commented Feb 24, 2018

Feature or Bugfix

  • Feature

Purpose

  • Enable to i18nize console messages (by locale envvars like LC_*)
  • Add new API to translate messages on extensions
  • Integrate l_() into _()
  • Refactor sphinx.locale module to do that.

@tk0miya tk0miya added this to the 1.8 milestone Feb 24, 2018
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):
Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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()`.
Copy link
Member Author

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.

Copy link
Member Author

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')
Copy link
Member Author

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.

Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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.

@tk0miya
Copy link
Member Author

tk0miya commented Feb 24, 2018

Oh, tests are broken. I'll check it later.

translator = translators.get((namespace, catalog))
# ignore previously failed attempts to find message catalogs
if isinstance(translator, gettext.NullTranslations):
if isinstance(translator, NullTranslations):
Copy link
Member Author

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

@codecov
Copy link

codecov bot commented Feb 25, 2018

Codecov Report

Merging #4674 into master will increase coverage by 0.04%.
The diff coverage is 90.07%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
sphinx/writers/texinfo.py 87.27% <ø> (ø) ⬆️
sphinx/cmdline.py 0% <0%> (ø) ⬆️
sphinx/cmd/build.py 0% <0%> (ø) ⬆️
sphinx/transforms/__init__.py 83.85% <0%> (ø) ⬆️
sphinx/testing/util.py 92.85% <100%> (+0.06%) ⬆️
sphinx/domains/javascript.py 85.52% <100%> (ø) ⬆️
sphinx/cmd/quickstart.py 69.14% <100%> (+0.35%) ⬆️
sphinx/writers/manpage.py 89.32% <100%> (ø) ⬆️
sphinx/builders/html.py 82.62% <100%> (ø) ⬆️
sphinx/domains/std.py 79.1% <100%> (ø) ⬆️
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d48e1ef...278577c. Read the comment docs.

@tk0miya tk0miya merged commit 8dbc1b5 into sphinx-doc:master Mar 1, 2018
@tk0miya tk0miya deleted the improve_i18n branch March 1, 2018 14:51
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants