Skip to content

Commit

Permalink
Use ngettext
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasr8 committed Jan 26, 2025
1 parent ea9e509 commit 98e5624
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions python_docs_theme/static/sidebar.js_t
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

const initialiseSidebar = () => {
const ngettext = Documentation.ngettext
// global elements used by the functions.
const bodyWrapper = document.querySelector(".bodywrapper")
const sidebar = document.querySelector(".sphinxsidebar")
Expand Down Expand Up @@ -57,7 +58,14 @@ const initialiseSidebar = () => {
sidebarbutton.role = "slider"
sidebarbutton.title = _("Resize sidebar")
sidebarbutton.setAttribute("aria-label", _("Resize sidebar by dragging"))
sidebarbutton.setAttribute("aria-valuetext", _("Sidebar width XXX pixels"))
sidebarbutton.setAttribute(
"aria-valuetext",
ngettext(
"Sidebar width {count} pixel",
"Sidebar width {count} pixels",
sidebar.offsetWidth
).replace("{count}", sidebar.offsetWidth)
)
let clientX;

function onMouseMove(e) {
Expand All @@ -79,7 +87,14 @@ const initialiseSidebar = () => {
document.addEventListener("mousemove", onMouseMove)
document.addEventListener("mouseup", () => {
document.removeEventListener("mousemove", onMouseMove)
sidebarbutton.setAttribute("aria-valuetext", _("Sidebar width XXX pixels"))
sidebarbutton.setAttribute(
"aria-valuetext",
ngettext(
"Sidebar width {count} pixel",
"Sidebar width {count} pixels",
sidebar.offsetWidth
).replace("{count}", sidebar.offsetWidth)
)
})
})

Expand Down

0 comments on commit 98e5624

Please sign in to comment.