Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
feat(i18n): deep-merge EN fallback to fill missing locale keys (B/G1)
diegosouzapwbff01d6fe326
diff --git a/src/i18n/request.ts b/src/i18n/request.tsindex e5eb20991c..0533cbed84 100644--- a/src/i18n/request.ts+++ b/src/i18n/request.ts@@ -3,23 +3,57 @@ import { cookies, headers } from "next/headers";import { LOCALES, DEFAULT_LOCALE, LOCALE_COOKIE } from "./config";import type { Locale } from "./config";+const FALLBACK_LOCALE = "en";++/**+ * Deep merge that mutates `target` with values from `source`.+ * If both have an object at the same key, recurse.+ * Otherwise prefer the existing value in `target` (locale-specific wins).+ */+export function deepMergeFallback(+ target: Record<string, unknown>,+ source: Record<string, unknown>+): Record<string, unknown> {+ for (const [key, sourceValue] of Object.entries(source)) {+ const targetValue = target[key];+ if (+ sourceValue !== null &&+ typeof sourceValue === "object" &&+ !Array.isArray(sourceValue) &&+ targetValue !== null &&+ typeof targetValue === "object" &&+ !Array.isArray(targetValue)+ ) {+ deepMergeFallback(targetValue as Record<string, unknown>, sourceValue as Record<string, unknown>);+ } else if (targetValue === undefined) {+ target[key] = sourceValue;+ }+ }+ return target;+}+export default getRequestConfig(async () => {- // 1. Try cookieconst cookieStore = await cookies();let locale: string = cookieStore.get(LOCALE_COOKIE)?.value || "";- // 2. Try custom header (set by middleware)if (!locale) {const headerStore = await headers();locale = headerStore.get("x-locale") || "";}- // 3. Validate & fallbackif (!LOCALES.includes(locale as Locale)) {locale = DEFAULT_LOCALE;}- const messages = (await import(`./messages/${locale}.json`)).default;+ const localeMessages = (await import(`./messages/${locale}.json`)).default;++ // G1: fall back to EN for any missing key. EN is loaded only once per request+ // and only when the active locale is not EN itself (no-op).+ let messages = localeMessages as Record<string, unknown>;+ if (locale !== FALLBACK_LOCALE) {+ const fallbackMessages = (await import(`./messages/${FALLBACK_LOCALE}.json`)).default as Record<string, unknown>;+ messages = deepMergeFallback({ ...localeMessages }, fallbackMessages);+ }return {locale,