Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
/**
|
|
* Lightweight i18n configuration for the Menivor web UI.
|
|
*
|
|
* This is a zero-dependency messages layer (no next-intl / react-i18next):
|
|
* a cookie selects the active locale, server components resolve it via
|
|
* `next/headers`, and client components read it from a React context seeded by
|
|
* the server. English is always the default and the fallback for any missing
|
|
* key, so adding a locale can never break a surface — untranslated strings
|
|
* degrade to English rather than to a raw key.
|
|
*/
|
|
|
|
/** Supported UI locales. English first — it is the default and fallback. */
|
|
export const LOCALES = ["en", "tr", "es"] as const;
|
|
|
|
export type Locale = (typeof LOCALES)[number];
|
|
|
|
/** Default/fallback locale. */
|
|
export const DEFAULT_LOCALE: Locale = "en";
|
|
|
|
/** Cookie that persists the visitor's chosen UI language. */
|
|
export const LOCALE_COOKIE = "menivor_locale";
|
|
|
|
/** One year, in seconds — the locale cookie's max-age. */
|
|
export const LOCALE_COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
|
|
|
|
/** Human-readable label shown in the language switcher, per locale. */
|
|
export const LOCALE_LABELS: Readonly<Record<Locale, string>> = {
|
|
en: "English",
|
|
tr: "Türkçe",
|
|
es: "Español",
|
|
};
|
|
|
|
/** Narrow an untrusted string to a supported `Locale`, else the default. */
|
|
export function normalizeLocale(value: string | null | undefined): Locale {
|
|
if (value && (LOCALES as readonly string[]).includes(value)) {
|
|
return value as Locale;
|
|
}
|
|
return DEFAULT_LOCALE;
|
|
}
|
|
|
|
/** Type guard for a supported locale. */
|
|
export function isLocale(value: unknown): value is Locale {
|
|
return (
|
|
typeof value === "string" && (LOCALES as readonly string[]).includes(value)
|
|
);
|
|
}
|