Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👌 IMPROVE: Change tabs to enable translation of headers #142

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion sphinx_tabs/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from sphinx.highlighting import lexer_classes
from sphinx.util.docutils import SphinxDirective
from sphinx.directives.code import CodeBlock
from sphinx.addnodes import translatable


FILES = [
Expand Down Expand Up @@ -49,9 +50,22 @@ class SphinxTabsPanel(nodes.container):
tagname = "div"


class SphinxTabsTab(nodes.paragraph):
class SphinxTabsTab(nodes.paragraph, translatable):
tagname = "button"

def preserve_original_messages(self):
if self.children[0].rawsource:
self["raw_text"] = self.children[0].rawsource

def apply_translated_message(self, original_message, translated_message):
if self.get("raw_text") == original_message:
self.children[0].rawsource = translated_message

def extract_original_messages(self):
if "raw_text" in self:
return [self["raw_text"]]
return []


class SphinxTabsTablist(nodes.container):
tagname = "div"
Expand Down