Files
wehub-resource-sync d68f003000
CI / Change detection (push) Has been cancelled
CI / Version drift (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Workflow RLM cache (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / npm wrapper smoke (push) Has been cancelled
CI / Mobile runtime smoke (push) Has been cancelled
CI / Workflow lint (push) Has been cancelled
CI / Documentation (push) Has been cancelled
Web Frontend / Lint & Type Check (push) Failing after 1s
Auto-close harvested PRs / close (push) Failing after 1s
cargo-deny / cargo-deny (bans licenses sources) (push) Failing after 1s
Security audit / cargo-audit (push) Failing after 1s
Sync to CNB / sync (push) Failing after 1s
cargo-deny / cargo-deny (advisories) (push) Failing after 3s
Web Frontend / Deploy to Cloudflare (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:08:23 +08:00

63 lines
2.4 KiB
TypeScript

/**
* Locale configuration for codewhale.net.
*
* SHIPPED locales have full website routes and dictionaries.
* PLANNED locales are tracked in docs/LOCALIZATION.md with target issues.
* DEFERRED locales are acknowledged but not yet scheduled.
*
* When adding a locale:
* 1. Add the code to the `locales` array below.
* 2. Add a label in web/components/locale-switcher.tsx → LOCALE_LABELS.
* 3. Scaffold dictionaries under web/lib/i18n/dictionaries/<code>/.
* 4. Update docs/LOCALIZATION.md.
*/
/** Status of a locale relative to the website. */
export type LocaleStatus = "shipped" | "partial" | "planned" | "deferred";
export interface LocaleEntry {
/** ISO 639-1 or IETF BCP 47 language tag used in routes. */
code: string;
/** Display label (native script). */
label: string;
/** Status relative to the website. */
status: LocaleStatus;
}
/**
* All locales the project tracks, ordered by priority.
*
* SHIPPED locales are included in `locales` (the constrained set used
* by Next.js route generation). PLANNED and DEFERRED locales are listed
* here for the matrix but not yet included in route generation.
*/
export const ALL_LOCALES: LocaleEntry[] = [
{ code: "en", label: "English", status: "shipped" },
{ code: "zh", label: "中文", status: "shipped" },
{ code: "ja", label: "日本語", status: "planned" },
{ code: "vi", label: "Tiếng Việt", status: "planned" },
{ code: "ko", label: "한국어", status: "planned" },
{ code: "ru", label: "Русский", status: "planned" },
{ code: "es", label: "Español", status: "deferred" },
{ code: "pt-BR", label: "Português (BR)", status: "deferred" },
{ code: "ar", label: "العربية", status: "deferred" },
];
/** Active website locales (used by Next.js route generation). */
export const locales = ALL_LOCALES.filter((l) => l.status === "shipped").map((l) => l.code) as readonly string[];
export type Locale = (typeof locales)[number];
export const defaultLocale: Locale = "en";
/** Set to "1" once the Gitee mirror at gitee.com/Hmbown/... exists. */
export const GITEE_ENABLED = process.env.NEXT_PUBLIC_GITEE_ENABLED === "1";
export function isValidLocale(x: string): x is Locale {
return (locales as readonly string[]).includes(x);
}
/** Check if a locale code is tracked (shipped, planned, or deferred). */
export function isTrackedLocale(x: string): boolean {
return ALL_LOCALES.some((l) => l.code === x);
}