sphinx-togglebutton icon indicating copy to clipboard operation
sphinx-togglebutton copied to clipboard

Is togglebutton_hint translatable?

Open mgeier opened this issue 5 years ago • 7 comments

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 ...

mgeier avatar Oct 20 '20 16:10 mgeier

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:

welcome[bot] avatar Oct 20 '20 16:10 welcome[bot]

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'])

choldgraf avatar Oct 20 '20 16:10 choldgraf

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.

mgeier avatar Oct 20 '20 17:10 mgeier

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

choldgraf avatar Oct 20 '20 17:10 choldgraf

This seems to work outside the Sphinx translation mechanism, right? I would prefer staying compatible with Sphinx's stuff and not reinvent translation.

mgeier avatar Oct 20 '20 17:10 mgeier

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 :-) )

choldgraf avatar Oct 20 '20 17:10 choldgraf