Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions .github/scripts/check-locale-surface.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
* as HTML numeric character references (#197) — into files no reader runs
* through an HTML parser, and in four places into the closing `)` of a link,
* which stops that link being a link. #197 fixed it at the producer with
* `patches/fumadocs-core@16.8.12.patch`, pinned to that exact version string,
* `patches/fumadocs-core@16.8.12.patch` (since #239, `@16.15.2.patch`), pinned to
* that exact version string,
* and #197 measured the defect in 16.15.1, 16.15.2 and 16.15.8 as well, so
* upgrading does not remove it. What a bump does to the pin, measured with
* pnpm 10.28.2 and #239's 16.15.2 (#282): a lockfile-updating install
Expand Down Expand Up @@ -1480,7 +1481,7 @@ function pageFindings({ surface, lang, pages, chrome, local = new Map() }) {
`${where}: ${name.where} "${name.value}" is a ${lang} chrome name (×${local.get(name.value)} on ` +
`the ${lang} pages) inside a lang="${name.lang}" region with no lang of its own — it is read to a ` +
`${lang} reader with English rules. Give the element lang="${lang}" (the heading-anchor and ` +
'code-copy buttons take it from `useI18n().locale` in `patches/fumadocs-ui@16.8.12.patch`)',
'code-copy buttons take it from `useI18n().locale` in `patches/fumadocs-ui@16.15.2.patch`)',
});
continue;
}
Expand Down Expand Up @@ -1977,7 +1978,7 @@ function gate() {
(pin.installed && pin.pinned.length && !pin.pinned.includes(pin.installed)
? ' — the pin does not name the installed version, so pnpm applied no patch to it. ' +
'Regenerate it against the new version (`pnpm patch fumadocs-core@<version>`), or drop it ' +
'if that version carries the upstream `peek` fix; see `patches/fumadocs-core@16.8.12.patch`.'
'if that version carries the upstream `peek` fix; see `patches/fumadocs-core@16.15.2.patch`.'
: ''),
);
console.log('');
Expand Down
14 changes: 5 additions & 9 deletions apps/docs/app/[lang]/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,13 @@ export default async function Page(props: {
/>
))}
{/*
`role="main"`: the page's main landmark (#308). Fumadocs 16.8.12
renders none anywhere in the docs layout, so a screen reader's "main"
jump went nowhere. DocsPage passes its other props to the `<article>`
it renders (breadcrumb, title, body, footer; not the sidebar or the
table of contents), and ARIA in HTML allows `main` on an article.
Upgrade note: fumadocs-ui 16.16.2 wraps that article in a `<main>` of
its own. On a version that does, delete this prop, or the page has two
main landmarks (`patches/fumadocs-ui@16.8.12.patch` says the same).
No `role` here. The page's main landmark (#308) is fumadocs-ui's own
since 16.15.2 at the latest: DocsPage's container renders
`<main className="contents">` around the `<article>` it passes these
props to. Under 16.8.12, which rendered no main landmark, this element
carried `role="main"`; keeping it now would give the page two.
*/}
<DocsPage
role="main"
toc={isFallback ? tocInLanguage(loaded.toc, contentLang) : loaded.toc}
full={page.data.full}
>
Expand Down
106 changes: 63 additions & 43 deletions apps/docs/lib/ui-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,35 @@ import zhHant from './ui-text/zh-Hant.json';
/**
* The docs site's interface copy — the chrome around a page, never the page.
*
* Two kinds of string live here. The first nineteen keys are Fumadocs' own
* `Translations` (the search box, "On this page", "Choose a language", the
* Two kinds of string live here. The first twenty keys are the strings
* Fumadocs renders (the search box, "On this page", "Choose a language", the
* previous/next footer, the accessible names of its icon buttons, …);
* `fumadocsTranslations()` hands exactly those to `RootProvider`, which is the
* only channel Fumadocs reads them through. The rest are this app's own
* controls and notices, read by the docs page and the 404 page.
* `fumadocsTranslations()` maps exactly those onto Fumadocs' own
* `Translations` keys and hands them to `RootProvider`, which is the only
* channel Fumadocs reads them through. The rest are this app's own controls
* and notices, read by the docs page and the 404 page.
*
* English is the source, written here and nowhere else (AGENTS.md rule 1). The
* Fumadocs values are its built-in defaults verbatim, so the English site
* renders byte-identically to before this table existed.
*
* Nine of the Fumadocs keys — `searchOpen` through `navMain` — do not exist in
* fumadocs-ui 16.8.12 as published: there the names are English literals in
* the components, outside the Translations API, so every locale page announced
* "Open Search" and "Copy Anchor Link" inside `<html lang="de">`.
* `patches/fumadocs-ui@16.8.12.patch` adds them: eight are a backport of
* upstream 16.9.0's own fix (the same key names, the same English defaults),
* and `navMain` replaces the `aria-label="Main"` Radix's navigation menu puts
* on the legal pages' header, which upstream has not localized. They arrive
* here through the one channel the other ten already use. The patch header
* says why a patch rather than slot overrides, and when it can go.
* Since fumadocs-ui 16.10, Fumadocs' `Translations` are keyed by the English
* string plus its notes (`"Open Search(search trigger)(aria-label)"`), not by
* name, so the keys here are this app's own names and
* `fumadocsTranslations()` is the one place that knows the mapping. Ten of
* them — `searchOpen` through `menuToggle` — are the icon buttons'
* accessible names. Eight of those 16.8.12 hard-coded in English outside its
* Translations API (#305), and upstream has read them through it since 16.9.0.
* `searchClose` and `sidebarClose` arrived with 16.15.2: the search dialog's
* close button, which had no name before, and the name the sidebar button
* takes while the mobile drawer is open. Both render only after interaction,
* so no prerendered page carries them and `check-locale-surface.mjs` cannot
* see them; they are here so that they are not English on a localized page.
* `navMain` names the legal pages' header navigation, which Radix labels
* "Main" and upstream still does not localize:
* `patches/fumadocs-ui@16.15.2.patch` reads it through the same API under the
* key `"Main(navigation menu)(aria-label)"`, and the patch header says why a
* patch and when it can go.
*
* The locale tables are UI copy in app code — the shape `app/not-found.tsx`
* and `app/[lang]/privacy/page.tsx` already use — not `content/docs/`
Expand All @@ -52,13 +60,14 @@ const en = {
chooseLanguage: 'Choose a language',
nextPage: 'Next Page',
previousPage: 'Previous Page',
chooseTheme: 'Theme',
editOnGithub: 'Edit on GitHub',
/** The icon buttons' accessible names: no visible text, only `aria-label`. */
searchOpen: 'Open Search',
searchClose: 'Close Search',
themeToggle: 'Toggle Theme',
sidebarOpen: 'Open Sidebar',
sidebarCollapse: 'Collapse Sidebar',
sidebarClose: 'Close Sidebar',
headingCopyAnchor: 'Copy Anchor Link',
codeBlockCopy: 'Copy Text',
codeBlockCopied: 'Copied Text',
Expand Down Expand Up @@ -102,17 +111,21 @@ const en = {
* the Simplified one like every other string in this table.
*/
notFound: 'This page could not be found.',
} satisfies Translations & Record<string, string>;
} satisfies Record<string, string>;

export type UiText = Record<keyof typeof en, string>;

/**
* Fumadocs' `Translations`, restated as a type alias. Same keys, same values;
* the difference is that an alias satisfies the index signature of the
* provider's `translations` prop (`TranslationsOption`) and an interface
* cannot, so the interface would not type-check at the one place it is used.
* The subset of Fumadocs' `Translations` this site supplies. Optional per key,
* because Fumadocs falls back to its English for a key it is not given and
* most of its keys belong to components this site does not render (the type
* table, the glass layout, its own page actions). Exact per key all the same:
* `fumadocsTranslations()` returns an object literal of this type, so a key
* Fumadocs renamed or dropped — or the patched navigation key, if the patch
* stops applying — is an excess-property error in `tsc`, not an English name
* on a localized page.
*/
export type FumadocsTranslations = { [K in keyof Translations]: Translations[K] };
export type FumadocsTranslations = { [K in keyof Translations]?: Translations[K] };

type Locale = (typeof i18n.languages)[number];

Expand Down Expand Up @@ -185,32 +198,39 @@ export function uiText(lang: string): UiText {
}

/**
* Exactly the strings Fumadocs reads, for `RootProvider`'s `i18n.translations`.
* Exactly the strings Fumadocs reads, for `RootProvider`'s `i18n.translations`,
* under Fumadocs' own keys.
*
* Picked rather than spread: the provider merges whatever it is given into the
* context every Fumadocs component reads, and this app's own keys have no
* business there. It also keeps the serialized client prop to nineteen strings.
* business there. Two app strings each feed two Fumadocs keys, because
* Fumadocs notes the same English twice: "Search" in the dialog and on the
* trigger, and "Choose a language" as the picker's heading and as its button's
* name.
*/
export function fumadocsTranslations(text: UiText): FumadocsTranslations {
return {
search: text.search,
searchNoResult: text.searchNoResult,
toc: text.toc,
tocNoHeadings: text.tocNoHeadings,
lastUpdate: text.lastUpdate,
chooseLanguage: text.chooseLanguage,
nextPage: text.nextPage,
previousPage: text.previousPage,
chooseTheme: text.chooseTheme,
editOnGithub: text.editOnGithub,
searchOpen: text.searchOpen,
themeToggle: text.themeToggle,
sidebarOpen: text.sidebarOpen,
sidebarCollapse: text.sidebarCollapse,
headingCopyAnchor: text.headingCopyAnchor,
codeBlockCopy: text.codeBlockCopy,
codeBlockCopied: text.codeBlockCopied,
menuToggle: text.menuToggle,
navMain: text.navMain,
'Search(search dialog)': text.search,
'Search(search trigger)': text.search,
'No results found(search dialog)': text.searchNoResult,
'On this page(table of contents)': text.toc,
'No Headings(table of contents)': text.tocNoHeadings,
'Last updated on(page footer)': text.lastUpdate,
'Choose a language(language switcher)': text.chooseLanguage,
'Choose a language(language switcher)(aria-label)': text.chooseLanguage,
'Next Page(pagination)': text.nextPage,
'Previous Page(pagination)': text.previousPage,
'Edit on GitHub(edit page)': text.editOnGithub,
'Open Search(search trigger)(aria-label)': text.searchOpen,
'Close Search(search dialog)(aria-label)': text.searchClose,
'Toggle Theme(theme switcher)(aria-label)': text.themeToggle,
'Open Sidebar(sidebar)(aria-label)': text.sidebarOpen,
'Collapse Sidebar(sidebar)(aria-label)': text.sidebarCollapse,
'Close Sidebar(sidebar)(aria-label)': text.sidebarClose,
'Copy Anchor Link(heading anchor)(aria-label)': text.headingCopyAnchor,
'Copy Text(code block)(aria-label)': text.codeBlockCopy,
'Copied Text(code block)(aria-label)': text.codeBlockCopied,
'Toggle Menu(mobile menu)(aria-label)': text.menuToggle,
'Main(navigation menu)(aria-label)': text.navMain,
};
}
3 changes: 2 additions & 1 deletion apps/docs/lib/ui-text/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"chooseLanguage": "Sprache wählen",
"nextPage": "Nächste Seite",
"previousPage": "Vorherige Seite",
"chooseTheme": "Design",
"editOnGithub": "Auf GitHub bearbeiten",
"searchOpen": "Suche öffnen",
"searchClose": "Suche schließen",
"themeToggle": "Design wechseln",
"sidebarOpen": "Seitenleiste öffnen",
"sidebarCollapse": "Seitenleiste einklappen",
"sidebarClose": "Seitenleiste schließen",
"headingCopyAnchor": "Ankerlink kopieren",
"codeBlockCopy": "Text kopieren",
"codeBlockCopied": "Text kopiert",
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/lib/ui-text/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"chooseLanguage": "Elegir idioma",
"nextPage": "Página siguiente",
"previousPage": "Página anterior",
"chooseTheme": "Tema",
"editOnGithub": "Editar en GitHub",
"searchOpen": "Abrir la búsqueda",
"searchClose": "Cerrar la búsqueda",
"themeToggle": "Cambiar de tema",
"sidebarOpen": "Abrir la barra lateral",
"sidebarCollapse": "Contraer la barra lateral",
"sidebarClose": "Cerrar la barra lateral",
"headingCopyAnchor": "Copiar enlace de anclaje",
"codeBlockCopy": "Copiar texto",
"codeBlockCopied": "Texto copiado",
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/lib/ui-text/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"chooseLanguage": "Choisir une langue",
"nextPage": "Page suivante",
"previousPage": "Page précédente",
"chooseTheme": "Thème",
"editOnGithub": "Modifier sur GitHub",
"searchOpen": "Ouvrir la recherche",
"searchClose": "Fermer la recherche",
"themeToggle": "Changer de thème",
"sidebarOpen": "Ouvrir la barre latérale",
"sidebarCollapse": "Réduire la barre latérale",
"sidebarClose": "Fermer la barre latérale",
"headingCopyAnchor": "Copier le lien d'ancre",
"codeBlockCopy": "Copier le texte",
"codeBlockCopied": "Texte copié",
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/lib/ui-text/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"chooseLanguage": "言語を選択",
"nextPage": "次のページ",
"previousPage": "前のページ",
"chooseTheme": "テーマ",
"editOnGithub": "GitHub で編集",
"searchOpen": "検索を開く",
"searchClose": "検索を閉じる",
"themeToggle": "テーマを切り替える",
"sidebarOpen": "サイドバーを開く",
"sidebarCollapse": "サイドバーを折りたたむ",
"sidebarClose": "サイドバーを閉じる",
"headingCopyAnchor": "アンカーリンクをコピー",
"codeBlockCopy": "テキストをコピー",
"codeBlockCopied": "テキストをコピーしました",
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/lib/ui-text/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"chooseLanguage": "언어 선택",
"nextPage": "다음 페이지",
"previousPage": "이전 페이지",
"chooseTheme": "테마",
"editOnGithub": "GitHub에서 편집",
"searchOpen": "검색 열기",
"searchClose": "검색 닫기",
"themeToggle": "테마 전환",
"sidebarOpen": "사이드바 열기",
"sidebarCollapse": "사이드바 접기",
"sidebarClose": "사이드바 닫기",
"headingCopyAnchor": "앵커 링크 복사",
"codeBlockCopy": "텍스트 복사",
"codeBlockCopied": "텍스트 복사됨",
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/lib/ui-text/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"chooseLanguage": "选择语言",
"nextPage": "下一页",
"previousPage": "上一页",
"chooseTheme": "主题",
"editOnGithub": "在 GitHub 上编辑",
"searchOpen": "打开搜索",
"searchClose": "关闭搜索",
"themeToggle": "切换主题",
"sidebarOpen": "打开侧边栏",
"sidebarCollapse": "收起侧边栏",
"sidebarClose": "关闭侧边栏",
"headingCopyAnchor": "复制锚点链接",
"codeBlockCopy": "复制文本",
"codeBlockCopied": "已复制文本",
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/lib/ui-text/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"chooseLanguage": "選擇語言",
"nextPage": "下一頁",
"previousPage": "上一頁",
"chooseTheme": "主題",
"editOnGithub": "在 GitHub 上編輯",
"searchOpen": "開啟搜尋",
"searchClose": "關閉搜尋",
"themeToggle": "切換主題",
"sidebarOpen": "開啟側邊欄",
"sidebarCollapse": "收起側邊欄",
"sidebarClose": "關閉側邊欄",
"headingCopyAnchor": "複製錨點連結",
"codeBlockCopy": "複製文本",
"codeBlockCopied": "已複製文本",
Expand Down
8 changes: 4 additions & 4 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
"cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts"
},
"dependencies": {
"fumadocs-core": "16.8.12",
"fumadocs-core": "16.15.2",
"fumadocs-mdx": "15.0.7",
"fumadocs-ui": "16.8.12",
"lucide-react": "^1.16.0",
"fumadocs-ui": "16.15.2",
"lucide-react": "^1.51.0",
"next": "16.2.6",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"tailwind-merge": "^3.6.0"
},
"devDependencies": {
"@opennextjs/cloudflare": "^1.13.0",
"@opennextjs/cloudflare": "^1.20.8",
"@tailwindcss/postcss": "^4.3.3",
"@types/mdx": "^2.0.13",
"@types/negotiator": "^0.6.5",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"sharp"
],
"patchedDependencies": {
"fumadocs-core@16.8.12": "patches/fumadocs-core@16.8.12.patch",
"fumadocs-ui@16.8.12": "patches/fumadocs-ui@16.8.12.patch"
"fumadocs-core@16.15.2": "patches/fumadocs-core@16.15.2.patch",
"fumadocs-ui@16.15.2": "patches/fumadocs-ui@16.15.2.patch"
}
}
}
Loading
Loading