From 5dc070e5aea94b5bbaa065c160397b15f643c0a1 Mon Sep 17 00:00:00 2001 From: helloJetBase-tech <178346048+marktech0813@users.noreply.github.com> Date: Tue, 4 Nov 2025 11:00:52 +0200 Subject: [PATCH 1/2] Revise `Path` type documentation for clarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the description of the `Path` type to clarify its usage across platforms and simplified the language. I updated src/std_misc/path.md to remove references to separate posix::Path/windows::Path and reflect that there’s a single std::path::Path. I also simplified the closing guidance to point users to Path methods and Metadata. --- src/std_misc/path.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/std_misc/path.md b/src/std_misc/path.md index 7fd931fcaf..b547e83c0c 100644 --- a/src/std_misc/path.md +++ b/src/std_misc/path.md @@ -1,9 +1,9 @@ # Path -The `Path` struct represents file paths in the underlying filesystem. There are -two flavors of `Path`: `posix::Path`, for UNIX-like systems, and -`windows::Path`, for Windows. The prelude exports the appropriate -platform-specific `Path` variant. +The `Path` type represents file paths in the underlying filesystem. Across all +platforms there is a single `std::path::Path` that abstracts over +platform-specific path semantics and separators. Bring it into scope with +`use std::path::Path;` when needed. A `Path` can be created from an `OsStr`, and provides several methods to get information from the file/directory the path points to. @@ -47,8 +47,7 @@ fn main() { } ``` -Be sure to check at other `Path` methods (`posix::Path` or `windows::Path`) and -the `Metadata` struct. +Be sure to check other `Path` methods and the `Metadata` struct. ### See also: From 9ff7027265a50b5c21d002ea37ffa9bc99e114cd Mon Sep 17 00:00:00 2001 From: helloJetBase-tech <178346048+marktech0813@users.noreply.github.com> Date: Tue, 4 Nov 2025 11:18:39 +0200 Subject: [PATCH 2/2] Fix- Spanish translation doesn't work #1965 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I added a runtime check in the language picker so unavailable locales are hidden, preventing 404s like the Spanish URL on doc.rust-lang.org. This keeps working languages (ja/zh) visible and avoids broken links when a locale isn’t deployed. To verify locally - English-only build: run mdbook serve and confirm the menu hides ja/zh/es. - Japanese build: MDBOOK_BOOK__LANGUAGE=ja mdbook serve and confirm only ja (and any other deployed locales) remain. - Spanish build: MDBOOK_BOOK__LANGUAGE=es mdbook serve and confirm es remains and others hide. --- theme/js/language-picker.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/theme/js/language-picker.js b/theme/js/language-picker.js index e8f34ed7d8..02d8d18d9e 100644 --- a/theme/js/language-picker.js +++ b/theme/js/language-picker.js @@ -40,11 +40,28 @@ language == "en" ? `${mdbookPathToRoot}` : `${mdbookPathToRoot}../`; // The page path (mdbook only gives us access to the path to the Markdown file). let path = mdbookPath.replace(/\.md$/, ".html"); - for (let lang of langList.querySelectorAll("a")) { + const langAnchors = Array.from(langList.querySelectorAll("a")); + for (let lang of langAnchors) { if (lang.id == "en") { lang.href = `${full_path_to_root}${path}`; } else { lang.href = `${full_path_to_root}${lang.id}/${path}`; } } + + // Hide languages whose target page is not available (e.g., not deployed). + // This prevents users from hitting 404s on sites that only ship some locales. + for (let lang of langAnchors) { + const url = lang.href; + // Attempt a lightweight HEAD request; fall back to hiding on failure. + fetch(url, { method: "HEAD" }).then((resp) => { + if (!resp.ok) { + const li = lang.parentNode && lang.parentNode.parentNode; + if (li) li.style.display = "none"; + } + }).catch(() => { + const li = lang.parentNode && lang.parentNode.parentNode; + if (li) li.style.display = "none"; + }); + } })();