Skip to content

Commit

Permalink
Make announcement banner into a landmark (aside/complementary) (#1793)
Browse files Browse the repository at this point in the history
* Make announcement banner into a landmark (aside/complementary)

* Generate/update the message catalog template (POT file) with the PyBabel extract command:

pybabel extract . -F babel.cfg -o src/pydata_sphinx_theme/locale/sphinx.pot -k '_ __ l_ lazy_gettext'

* Update the message catalogs (PO files) with the PyBabel update command:

pybabel update -i src/pydata_sphinx_theme/locale/sphinx.pot -d src/pydata_sphinx_theme/locale -D sphinx
  • Loading branch information
gabalafou committed May 7, 2024
1 parent e67f64d commit 779c3e0
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/pydata_sphinx_theme/locale/ca/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-03-11 13:22-0500\n"
"POT-Creation-Date: 2024-04-29 13:43+0200\n"
"PO-Revision-Date: 2023-04-14 14:57+0000\n"
"Last-Translator: Cristhian Rivera, 2024\n"
"Language: ca\n"
Expand Down Expand Up @@ -156,6 +156,10 @@ msgstr ""
"theme.readthedocs.io/en/stable/index.html\">Tema PyData Sphinx</a> "
"%(theme_version)s."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html:1
msgid "Announcement"
msgstr ""

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header.html:3
#, fuzzy
msgid "Site navigation"
Expand Down
6 changes: 5 additions & 1 deletion src/pydata_sphinx_theme/locale/cs/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-03-11 13:22-0500\n"
"POT-Creation-Date: 2024-04-29 13:43+0200\n"
"PO-Revision-Date: 2023-04-14 14:57+0000\n"
"Last-Translator: Jan Breuer <[email protected]>, 2024\n"
"Language: cs\n"
Expand Down Expand Up @@ -156,6 +156,10 @@ msgstr ""
"theme.readthedocs.io/en/stable/index.html\">PyData Sphinx Theme</a> "
"%(theme_version)s."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html:1
msgid "Announcement"
msgstr ""

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header.html:3
#, fuzzy
msgid "Site navigation"
Expand Down
6 changes: 5 additions & 1 deletion src/pydata_sphinx_theme/locale/en/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-03-11 13:22-0500\n"
"POT-Creation-Date: 2024-04-29 13:43+0200\n"
"PO-Revision-Date: 2023-02-16 13:19-0500\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
Expand Down Expand Up @@ -147,6 +147,10 @@ msgid ""
"%(theme_version)s."
msgstr ""

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html:1
msgid "Announcement"
msgstr ""

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header.html:3
msgid "Site navigation"
msgstr ""
Expand Down
6 changes: 5 additions & 1 deletion src/pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-03-11 13:22-0500\n"
"POT-Creation-Date: 2024-04-29 13:43+0200\n"
"PO-Revision-Date: 2023-04-14 14:57+0000\n"
"Last-Translator: Cristhian Rivera, 2024\n"
"Language: es\n"
Expand Down Expand Up @@ -157,6 +157,10 @@ msgstr ""
"theme.readthedocs.io/en/stable/index.html\">Tema PyData Sphinx</a> "
"%(theme_version)s."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html:1
msgid "Announcement"
msgstr ""

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header.html:3
#, fuzzy
msgid "Site navigation"
Expand Down
6 changes: 5 additions & 1 deletion src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-03-11 13:22-0500\n"
"POT-Creation-Date: 2024-04-29 13:43+0200\n"
"PO-Revision-Date: 2023-04-14 14:57+0000\n"
"Last-Translator: Rambaud Pierrick <[email protected]>, 2024\n"
"Language: fr\n"
Expand Down Expand Up @@ -156,6 +156,10 @@ msgstr ""
"theme.readthedocs.io/en/stable/index.html\">Thème PyData Sphinx</a> "
"%(theme_version)s."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html:1
msgid "Announcement"
msgstr ""

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header.html:3
#, fuzzy
msgid "Site navigation"
Expand Down
6 changes: 5 additions & 1 deletion src/pydata_sphinx_theme/locale/ru/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-03-11 13:22-0500\n"
"POT-Creation-Date: 2024-04-29 13:43+0200\n"
"PO-Revision-Date: 2023-04-14 14:57+0000\n"
"Last-Translator: Rambaud Pierrick <[email protected]>, 2023\n"
"Language: ru\n"
Expand Down Expand Up @@ -157,6 +157,10 @@ msgstr ""
"theme.readthedocs.io/en/stable/index.html\\\">PyData Sphinx</a> "
"%(theme_version)s."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html:1
msgid "Announcement"
msgstr ""

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header.html:3
#, fuzzy
msgid "Site navigation"
Expand Down
6 changes: 5 additions & 1 deletion src/pydata_sphinx_theme/locale/sphinx.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-03-11 13:22-0500\n"
"POT-Creation-Date: 2024-04-29 13:43+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -146,6 +146,10 @@ msgid ""
"%(theme_version)s."
msgstr ""

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html:1
msgid "Announcement"
msgstr ""

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header.html:3
msgid "Site navigation"
msgstr ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% set banner_label = _("Announcement") %}
{% set header_classes = ["bd-header-announcement", "container-fluid", "init"] %}
{% set is_remote=theme_announcement.startswith("http") %}
{# If we are remote, add a script to make an HTTP request for the value on page load #}
{%- if is_remote %}
<script>
document.write(`<div class="bd-header-announcement"></div>`);
document.write(`<aside class="bd-header-announcement" aria-label="{{ banner_label }}"></aside>`);
fetch("{{ theme_announcement }}")
.then(res => {return res.text();})
.then(data => {
Expand Down Expand Up @@ -42,7 +43,8 @@
</script>
{#- if announcement text is not remote, populate announcement w/ local content -#}
{%- else %}
<div class="{{ header_classes | join(' ') }} bd-header-announcement">
<aside class="{{ header_classes | join(' ') }} bd-header-announcement"
aria-label="{{ banner_label }}">
<div class="bd-header-announcement__content">{{ theme_announcement }}</div>
</div>
</aside>
{% endif %}

0 comments on commit 779c3e0

Please sign in to comment.