Skip to content

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

fix(i18n): auto-load .env in run-translation.mjs so npm scripts work standalone

diegosouzapwfb963154eadd
diff --git a/scripts/i18n/run-translation.mjs b/scripts/i18n/run-translation.mjs
index 5001716093..117ba0fd86 100755
--- a/scripts/i18n/run-translation.mjs
+++ b/scripts/i18n/run-translation.mjs
@@ -30,12 +30,42 @@
* OMNIROUTE_TRANSLATION_CONCURRENCY optional, default 4
*/
-import { promises as fs, existsSync } from "node:fs";
+import { promises as fs, existsSync, readFileSync } from "node:fs";
import path from "node:path";
import crypto from "node:crypto";
import process from "node:process";
import { fileURLToPath, pathToFileURL } from "node:url";
+// ----- .env loader --------------------------------------------------------
+// Loads variables from a local `.env` (gitignored) into process.env without
+// pulling dotenv as a dependency. Already-set env vars take precedence so the
+// shell / CI environment can still override.
+(function loadDotEnv() {
+ const envPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", ".env");
+ if (!existsSync(envPath)) return;
+ try {
+ const raw = readFileSync(envPath, "utf8");
+ for (const rawLine of raw.split(/\r?\n/)) {
+ const line = rawLine.trim();
+ if (!line || line.startsWith("#")) continue;
+ const eq = line.indexOf("=");
+ if (eq <= 0) continue;
+ const key = line.slice(0, eq).trim();
+ if (!key || process.env[key] !== undefined) continue;
+ let value = line.slice(eq + 1);
+ if (
+ (value.startsWith('"') && value.endsWith('"')) ||
+ (value.startsWith("'") && value.endsWith("'"))
+ ) {
+ value = value.slice(1, -1);
+ }
+ process.env[key] = value;
+ }
+ } catch {
+ /* ignore — script will fall back to the requireEnv error path */
+ }
+})();
+
// Prettier is loaded lazily on first use so the script still runs (with a
// warning) in environments where node_modules has not been installed. The
// formatter is applied to every translated file before its hash is recorded,