Files
multica/apps/web/lib/use-cases-source.ts
김보경/DAXTF 5aa4fb7487 MUL-2760: feat(i18n): add Korean locale support (#3369)
* feat: add korean locale support

* feat(i18n): localize Korean landing page

* fix(i18n): refine Korean landing copy

* fix(i18n): refine Korean translations

* fix(i18n): translate Korean landing subpages

* fix(i18n): route Korean landing docs links

* fix(i18n): add Korean use case content

* fix(i18n): polish Korean locale copy

* fix(i18n): improve Korean landing copy

* fix(onboarding): persist Korean helper artifacts

Co-authored-by: multica-agent <github@multica.ai>

* fix(web): add use case locale fallback

Co-authored-by: multica-agent <github@multica.ai>

* Align Korean pull requests wording

Co-authored-by: multica-agent <github@multica.ai>

* fix(i18n): dedupe docs href helper

Co-authored-by: multica-agent <github@multica.ai>

* fix(i18n): localize changelog dates

Co-authored-by: multica-agent <github@multica.ai>

* fix(docs): prerender Korean fallback pages

Co-authored-by: multica-agent <github@multica.ai>

* fix(docs): align fallback hreflang metadata

Co-authored-by: multica-agent <github@multica.ai>

* fix(i18n): preserve Chinese CJK font fallback order

Co-authored-by: multica-agent <github@multica.ai>

* chore(onboarding): update localized comment wording

Co-authored-by: multica-agent <github@multica.ai>

* test(i18n): harden CJK font fallback assertions

Co-authored-by: multica-agent <github@multica.ai>

* fix(docs): keep Chinese font fallbacks first

Co-authored-by: multica-agent <github@multica.ai>

* test(i18n): harden locale fallback coverage

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: multica-agent <github@multica.ai>
2026-05-29 15:16:22 +08:00

54 lines
1.6 KiB
TypeScript

import { loader } from "fumadocs-core/source";
import { defineI18n } from "fumadocs-core/i18n";
import type { SupportedLocale } from "@multica/core/i18n";
import { useCases } from "@/.source";
import { mergeUseCasePagesWithEnglishFallback } from "./use-case-locale-fallback";
// Use-case content uses dot-suffixed MDX files (`<slug>.en.mdx`,
// `<slug>.zh.mdx`, and `<slug>.ko.mdx`). The public route remains prefix-free; request locale is
// resolved through the same cookie/header path as the rest of the web app.
export const i18n = defineI18n({
languages: ["en", "zh", "ko"],
defaultLanguage: "en",
hideLocale: "default-locale",
parser: "dot",
});
export type UseCaseLang = (typeof i18n.languages)[number];
export function getUseCaseLangForLocale(locale: SupportedLocale): UseCaseLang {
if (locale === "zh-Hans") return "zh";
if (locale === "ko") return "ko";
return "en";
}
export const useCasesSource = loader({
baseUrl: "/usecases",
source: useCases.toFumadocsSource(),
i18n,
});
export function getUseCasePagesForLocale(locale: SupportedLocale) {
const lang = getUseCaseLangForLocale(locale);
const pages = useCasesSource.getPages(lang);
if (lang === i18n.defaultLanguage) return pages;
return mergeUseCasePagesWithEnglishFallback(
pages,
useCasesSource.getPages(i18n.defaultLanguage),
);
}
export function getUseCasePageForLocale(
slugs: string[],
locale: SupportedLocale,
) {
const lang = getUseCaseLangForLocale(locale);
const page = useCasesSource.getPage(slugs, lang);
if (page || lang === i18n.defaultLanguage) return page;
return useCasesSource.getPage(slugs, i18n.defaultLanguage);
}