-
Notifications
You must be signed in to change notification settings - Fork 234
Add Japanese localization of Academy at /academy/japan/ #3018
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
Open
kurosawa-gao
wants to merge
2
commits into
langfuse:main
Choose a base branch
from
gao-ai-com:feat/academy-japan
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import Link from "next/link"; | ||
|
|
||
| export default function JaAcademyNotFound() { | ||
| return ( | ||
| <div className="flex flex-col items-center justify-center gap-4 py-16 text-center"> | ||
| <h1 className="text-2xl font-semibold">ページが見つかりません</h1> | ||
| <p className="text-fd-muted-foreground"> | ||
| お探しのページは存在しないか、移動されました。 | ||
| </p> | ||
| <Link href="/academy/japan" className="text-fd-primary hover:underline"> | ||
| Academy トップへ | ||
| </Link> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import type { Metadata } from "next"; | ||
| import { notFound } from "next/navigation"; | ||
| import { academyJaSource } from "@/lib/source"; | ||
| import { DocsChromePage } from "@/components/DocsChromePage"; | ||
| import { buildSectionMetadata } from "@/lib/mdx-page"; | ||
|
|
||
| type PageProps = { | ||
| params: Promise<{ slug?: string[] }>; | ||
| }; | ||
|
|
||
| export default async function JaAcademyPage({ params }: PageProps) { | ||
| const { slug = [] } = await params; | ||
| const page = academyJaSource.getPage(slug); | ||
| if (!page) notFound(); | ||
| return ( | ||
| <DocsChromePage | ||
| page={page} | ||
| bottomSuffix={ | ||
| <div className="mt-10 text-right text-xs italic text-fd-muted-foreground"> | ||
| Translation by{" "} | ||
| <a | ||
| href="https://gao-ai.com" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| className="underline underline-offset-2 decoration-1 hover:no-underline" | ||
| > | ||
| GAO, Inc. | ||
| </a> | ||
| </div> | ||
| } | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export async function generateMetadata({ | ||
| params, | ||
| }: PageProps): Promise<Metadata> { | ||
| const { slug = [] } = await params; | ||
| const page = academyJaSource.getPage(slug); | ||
| if (!page) return { title: "Not Found" }; | ||
| return buildSectionMetadata(page, "academy/japan", "Academy", slug); | ||
| } | ||
|
|
||
| export function generateStaticParams() { | ||
| return academyJaSource | ||
| .generateParams() | ||
| .map((p) => (p.slug.length > 0 ? { slug: p.slug } : {})); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { academyJaSource } from "@/lib/source"; | ||
| import { SharedDocsLayout } from "@/components/layout"; | ||
|
|
||
| export default function JaAcademyLayout({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode; | ||
| }) { | ||
| return ( | ||
| <SharedDocsLayout tree={academyJaSource.getPageTree()}> | ||
| {children} | ||
| </SharedDocsLayout> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 The .map at line 105 iterates the locale-aware
stepsarray, but the connector guard at line 120 still referencesSTEPS.length(the English-only constant). BothSTEPSandSTEPS_JAhappen to have 5 entries today, so there is no user-visible defect, but a future contributor adding or removing a step from one array only would render an orphan connector or miss one. One-line fix:STEPS.length→steps.length.Extended reasoning...
What the bug is. This PR introduces a locale-aware
stepsarray (const steps = locale === "ja" ? STEPS_JA : STEPS) and correctly switches the.mapcall at line 105 fromSTEPS.maptosteps.map. However, the connector guard immediately below at line 120 still reads{i < STEPS.length - 1 && ...}, referencing the English-onlySTEPSconstant rather than the locale-selectedstepsarray.Why it's latent today.
STEPSandSTEPS_JAeach contain exactly 5 entries, soSTEPS.length === steps.lengthfor every supported locale and the rendered output is identical to usingsteps.length. No user will see a visual defect on this PR as it stands — this is purely a code-quality / consistency issue.Why it still matters. The diff introduced
stepsprecisely to abstract over locale, and one of the two sites that needs it was missed. The inconsistency is a footgun for future contributors: if someone adds or removes a step fromSTEPS_JA(or adds a third locale array, e.g.STEPS_DE) and forgets to make a matching edit toSTEPS, the connector count will no longer match the rendered step count — producing either an orphan trailing connector or a missing connector between the last two cards.Step-by-step proof. Suppose a future contributor adds a 6th step to
STEPS_JA:steps = STEPS_JAnow has length 6..mapat line 105 renders 6 step cards (indices i=0..5).i < STEPS.length - 1, i.e.i < 4(becauseSTEPS.lengthis still 5).STEPSwhileSTEPS_JAkeeps 5, an extra connector renders past the last card.How to fix. Change
STEPS.lengthtosteps.lengthon line 120 so the guard derives from the same array being iterated. This is the same one-line change Greptile-style reviewers would call out — defensive, consistent with the abstraction the diff introduced.