Can you rename the table of contents to the sphinx sidebar?

In general, how do you rename the default Sphinx items (e.g. Quick Search to Search )? Can you?

+6
source share
2 answers

Here's how you could change Quick Search to something else by overriding the template:

  • Create a folder called templates in the Sphinx project directory.

  • Copy <Sphinx install dir>/themes/basic/searchbox.html into templates .

  • In conf.py add

     templates_path = ["templates"] 
  • Rename “Quick Search” to everything you need in a copy of searchbox.html .

But I wouldn’t do that.

A more flexible approach is to create a gettext MO file and configure the configuration described in the documentation for locale_dirs . Like this:

  • The <Sphinx install dir>/locale/sphinx.pot template file contains all the lines that can be translated. Copy this file to the local sphinx.po file.

  • Add your changes to sphinx.po .

  • Use msgfmt.py to compile sphinx.po into sphinx.mo .

  • Place sphinx.mo in the appropriate directory ( <your_locale_dir>/en/LC_MESSAGES for English).

See also http://docs.python.org/library/gettext.html#internationalizing-your-programs-and-modules .

+5
source

According to the Sphinx config documentation, you should be able to modify the html templates or perhaps point Sphinx to new templates in order to achieve what you are trying to do while working on html templates.

Current templates have a search header provided in context, I'm not sure what fills the context value for _ ('search'). I wander if you can try to configure it by changing the locale file in /sphinx/sphinx/locale/sphinx.pot:

 #: sphinx/themes/agogo/layout.html:49 sphinx/themes/basic/layout.html:137 #: sphinx/themes/basic/search.html:11 sphinx/themes/basic/search.html:20 msgid "Search" msgstr "" 

and say msgstr "My alternative search" instead of msgstr "" .

+1
source

Source: https://habr.com/ru/post/893541/


All Articles