您可以将“目录”重命名吗?在狮身人面像侧边栏中?
更一般地说,如何重命名 Sphinx 默认元素(例如,将 Quick Search
重命名为 Search
)?你可以吗?
More generally how do you rename Sphinx default elements (e.g. Quick Search
to Search
)? Can you?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是如何通过覆盖模板将“快速搜索”更改为其他内容:
在 Sphinx 项目目录中创建一个名为
templates
的文件夹。将
/themes/basic/searchbox.html
复制到模板
。在conf.py中添加
Rename 'Quick search' 添加到
searchbox.html
副本中您想要的任何内容。但我不会这样做。
更灵活的方法是创建 gettext MO 文件并按照 locale_dirs 文档中所述设置配置。像这样:
模板文件
/locale/sphinx.pot
包含所有可以翻译的字符串。将该文件复制到本地sphinx.po
文件。将您的更改添加到
sphinx.po
。使用msgfmt.py将
sphinx.po
编译为sphinx.mo
。将
sphinx.mo
放入正确的目录(对于英语,/en/LC_MESSAGES
)。另请参阅 http://docs.python.org/library/gettext.html#国际化您的程序和模块。
Here is how you could change "Quick search" to something else by overriding a template:
Create a folder called
templates
in the Sphinx project directory.Copy
<Sphinx install dir>/themes/basic/searchbox.html
totemplates
.In conf.py, add
Rename 'Quick search' to whatever you want in the copy of
searchbox.html
.But I would not do it this way.
A more flexible approach is to create a gettext MO file and set up the configuration as described in the documentation for locale_dirs. Like this:
The template file
<Sphinx install dir>/locale/sphinx.pot
contains all the strings that can be translated. Copy that file to a localsphinx.po
file.Add your changes to
sphinx.po
.Use msgfmt.py to compile
sphinx.po
intosphinx.mo
.Put
sphinx.mo
in the proper directory (<your_locale_dir>/en/LC_MESSAGES
for English).See also http://docs.python.org/library/gettext.html#internationalizing-your-programs-and-modules.
根据Sphinx配置文档,您应该能够修改html模板或者将Sphinx指向新的模板来通过处理模板的 html 来实现您想要做的事情。
当前模板在上下文中提供了搜索标题,但我不确定填充 _('search') 的上下文值的内容是什么。我想知道您是否可以尝试通过修改 /sphinx/sphinx/locale/sphinx.pot 中的区域设置文件来自定义它:
并说
msgstr“我的替代搜索”
而不是msgstr“”.
According to Sphinx config documentation, you should be able to amend the html templates or perhaps point Sphinx to new templates to achieve what you trying to do by working on the templates' html.
Current templates have search title provided in the context, I am not sure though what populates context value for _('search'). I wander if you could try customizing it by amending the locale file in /sphinx/sphinx/locale/sphinx.pot:
and say
msgstr "My alternative search"
instead ofmsgstr ""
.