sphinx-togglebutton
sphinx-togglebutton copied to clipboard
Is togglebutton_hint translatable?
I'm not quite sure how Sphinx's translation system works, sorry for the naive question.
It's nice to have the togglebutton_hint string configurable, but I'm not sure whether that's enough (or the right way) to make it translatable.
There are other Sphinx features like copyright, which have a conf.py option but also have special markup in the HTML template in order to be translatable. At least that's how I understand it ...
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
It should be translateable but is not currently.
I believe we'd need to use this pattern:
https://github.com/executablebooks/sphinx-book-theme/blob/master/sphinx_book_theme/topbar.html#L20
here:
https://github.com/executablebooks/sphinx-togglebutton/blob/master/sphinx_togglebutton/init.py#L16
(and access the translate function in Python via context['translate'])
The place I was referring to is https://github.com/sphinx-doc/sphinx/blob/0476e1cea93b587e3c0ab295aa20b2b9f0f81a34/sphinx/themes/basic/layout.html#L206 using the trans thingie.
I don't know which is more appropriate here.
ahh right - perhaps here is another pattern we could follow:
https://github.com/executablebooks/sphinx-copybutton/blob/master/sphinx_copybutton/_static/copybutton.js_t#L25
https://github.com/executablebooks/sphinx-copybutton/blob/master/sphinx_copybutton/_static/copybutton.js_t#L2
This seems to work outside the Sphinx translation mechanism, right? I would prefer staying compatible with Sphinx's stuff and not reinvent translation.
well it's not using Sphinx's translation mechanism directly, but seems to be piggy-backing on the language that Sphinx sets in the environment. (note: I didn't implement that above, another contributor did, so I am trying to backwards engineer this as much as you are :-) )