diff --git a/components/search-dialog.tsx b/components/search-dialog.tsx index 4812a50..cf68204 100644 --- a/components/search-dialog.tsx +++ b/components/search-dialog.tsx @@ -3,7 +3,6 @@ import { useMemo, useState } from 'react'; import { useDocsSearch } from 'fumadocs-core/search/client'; import type { SearchLink, SharedProps } from 'fumadocs-ui/contexts/search'; -import { useI18n } from 'fumadocs-ui/contexts/i18n'; import { SearchDialog, SearchDialogClose, @@ -27,12 +26,10 @@ export function CovenSearchDialog({ links = [], ...props }: SharedProps & { links?: SearchLink[] }) { - const { locale } = useI18n(); const [tag, setTag] = useState(); const [filterOpen, setFilterOpen] = useState(false); const { search, setSearch, query } = useDocsSearch({ type: 'fetch', - locale, tag, }); diff --git a/package.json b/package.json index f38aced..733c0e8 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,9 @@ "type": "module", "scripts": { "dev": "next dev", - "build": "next build", + "build": "npm run check:english-only && next build", "check:fumadocs": "node scripts/check-fumadocs-platform.mjs", + "check:english-only": "node scripts/check-english-only.mjs", "check:links": "node scripts/validate-links.mjs", "check:mermaid": "node scripts/check-mermaid-transform.mjs && node scripts/check-mermaid-svg-normalize.mjs", "export:pdf": "node scripts/export-pdf.mjs", diff --git a/scripts/check-english-only.mjs b/scripts/check-english-only.mjs new file mode 100644 index 0000000..67219c5 --- /dev/null +++ b/scripts/check-english-only.mjs @@ -0,0 +1,63 @@ +import fs from 'node:fs'; +import path from 'node:path'; + +const root = process.cwd(); +const forbiddenLocaleDirs = new Set([ + 'ar', + 'de', + 'es', + 'fr', + 'it', + 'ja', + 'ko', + 'pt', + 'ru', + 'zh', + 'zh-CN', + 'zh-TW', +]); +const ignoredDirs = new Set(['.git', '.next', '.source', 'node_modules']); + +function walk(dir) { + const entries = fs.readdirSync(dir, { withFileTypes: true }); + const matches = []; + + for (const entry of entries) { + if (!entry.isDirectory()) continue; + if (ignoredDirs.has(entry.name)) continue; + + const entryPath = path.join(dir, entry.name); + const relative = path.relative(root, entryPath).replace(/\\/g, '/'); + + if (forbiddenLocaleDirs.has(entry.name)) { + matches.push(relative); + continue; + } + + matches.push(...walk(entryPath)); + } + + return matches; +} + +const localeDirectories = walk(root); +if (localeDirectories.length > 0) { + throw new Error(`Non-English locale directories are not allowed:\n${localeDirectories.join('\n')}`); +} + +const searchDialog = fs.readFileSync(path.join(root, 'components/search-dialog.tsx'), 'utf8'); +if (searchDialog.includes('useI18n') || searchDialog.includes('locale,')) { + throw new Error('Search must stay English-only and must not depend on Fumadocs locale context.'); +} + +const rootLayout = fs.readFileSync(path.join(root, 'app/layout.tsx'), 'utf8'); +if (!rootLayout.includes('