0

I'd like to overwrite admonition labels. Admonitions are directives such as note, warning, and so on.

For Japanese, the labels are defined in https://github.com/sphinx-doc/sphinx/blob/master/sphinx/locale/ja/LC_MESSAGES/sphinx.po.

Is there a simple way to overwrite them without changing the master repository?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Junichi Sakaeda
  • 553
  • 4
  • 4
  • I don't know, but I would start by reading the documentation at https://www.sphinx-doc.org/en/master/usage/advanced/intl.html. If that does not help, then I would search its [issue tracker](https://github.com/sphinx-doc/sphinx/issues), and if none is relevant then create a new issue. – Steve Piercy Jan 04 '21 at 02:16

1 Answers1

1

Here is what works for me (tested with Sphinx 3.3.1):

  1. Copy the Japanese sphinx.po from <sphinx_install_dir>/sphinx/locale/ja/LC_MESSAGES/

    to <your_sphinx_proj>/locales/ja/LC_MESSAGES/.

    Note the directory name locales (the default value of the locale_dirs configuration option).

  2. Edit msgstr for the relevant entries (admonitions in this case) in the copy of sphinx.po.

    It is not necessary to keep the entire copy. You can remove the unchanged entries if you want.

  3. Run sphinx-build with language=ja (set it in conf.py or on the command line). A local project-specific sphinx.mo file is generated and used in the build.

This means that there will be two *.mo files for the same domain ("sphinx"). The local sphinx.mo is consulted first, and the original sphinx.mo that comes with Sphinx is used as the fallback.

mzjn
  • 48,958
  • 13
  • 128
  • 248