diff --git a/.babel.cfg b/.babel.cfg index cc4c9de..692580d 100644 --- a/.babel.cfg +++ b/.babel.cfg @@ -1,3 +1 @@ -[javascript: **.js] - [jinja2: **.html] diff --git a/python_docs_theme/layout.html b/python_docs_theme/layout.html index 1023258..ab1cfe3 100644 --- a/python_docs_theme/layout.html +++ b/python_docs_theme/layout.html @@ -74,7 +74,10 @@

{{ _('Navigation') }}

{%- if builder != "htmlhelp" %} {%- if not embedded %} - + diff --git a/python_docs_theme/static/copybutton.js b/python_docs_theme/static/copybutton.js index f90eb1e..88ee0c6 100644 --- a/python_docs_theme/static/copybutton.js +++ b/python_docs_theme/static/copybutton.js @@ -23,12 +23,14 @@ function getCopyableText(rootElement) { return rootElement.innerText.trim() } +const copyButtonLabels = document.currentScript.dataset + const loadCopyButton = () => { const button = document.createElement("button") button.classList.add("copybutton") button.type = "button" - button.innerText = _("Copy") - button.title = _("Copy to clipboard") + button.innerText = copyButtonLabels.copy + button.title = copyButtonLabels.copyToClipboard const makeOnButtonClick = () => { let timeout = null @@ -50,9 +52,9 @@ const loadCopyButton = () => { return } - buttonEl.innerText = _("Copied!") + buttonEl.innerText = copyButtonLabels.copied timeout = setTimeout(() => { - buttonEl.innerText = _("Copy") + buttonEl.innerText = copyButtonLabels.copy }, 1500) } }