Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): Add i18n support for English and Japanese #11690

Closed
wants to merge 7 commits into from
Closed
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
16 changes: 16 additions & 0 deletions docs/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { NextResponse } from "next/server"
import type { NextRequest } from "next/server"

export function middleware(request: NextRequest) {
const requestUrl = new URL(request.url)
return NextResponse.redirect(
new URL(
`/en${requestUrl.pathname}${requestUrl.search}${requestUrl.hash}`,
request.url
)
)
}

export const config = {
matcher: "/((?!api|_next/static|_next/image|favicon.ico|en|jp).+)",
}
9 changes: 9 additions & 0 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ export default withNextra({
source: "/guides",
destination: "/guides/debugging",
},
{
source: "/",
destination: "/en",
permanent: true,
},
]
},
i18n: {
locales: ["en", "ja"],
defaultLocale: "en",
},
})
4 changes: 4 additions & 0 deletions docs/theme.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ const config: DocsThemeConfig = {
footer: {
component: <Footer />,
},
i18n: [
{ locale: "en", name: "English" },
{ locale: "ja", name: "日本語(ベータ)" },
],
}

export default config
17 changes: 8 additions & 9 deletions docs/typedoc-nextauth.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,19 @@ function writeMetaJsFiles(app) {
}
})

// Rename generated 'next-auth' dir to 'nextjs'
if (new RegExp(".*docs/pages/reference/nextjs$").test(outputDirectory)) {
if (fs.existsSync("./pages/reference/nextjs")) {
fs.rmdirSync("./pages/reference/nextjs", { recursive: true })
}
fs.renameSync("./pages/reference/next-auth", "./pages/reference/nextjs")
}

const metaJString = `
export default ${JSON.stringify(pages, null, 2)}`
if (new RegExp(".*docs/pages/reference$").test(outputDirectory)) return
if (new RegExp(".*docs/pages/en/reference$").test(outputDirectory)) return
fs.writeFileSync(path.join(outputDirectory, "_meta.js"), metaJString)
}

// Rename generated 'next-auth' dir to 'nextjs'
const nextjsPath = "./pages/en/reference/nextjs"
if (fs.existsSync(nextjsPath)) {
fs.rmdirSync(nextjsPath, { recursive: true })
}
fs.renameSync("./pages/en/reference/next-auth", nextjsPath)

/**
* Recursively write _meta.js files for each page based on output.navigation
*/
Expand Down
2 changes: 1 addition & 1 deletion docs/typedoc.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
// typedoc options
entryPoints: [...frameworks, ...adapters],
entryPointStrategy: "packages",
out: "pages/reference",
out: "pages/en/reference",
tsconfig: "./tsconfig.json",
plugin: [
"typedoc-plugin-markdown",
Expand Down
Loading