Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Every language follows the same locale rule: missing strings fall back to English
milind-sonib561a8fca1a6
diff --git a/docs/localization-pt-br.md b/docs/localization-pt-br.mdindex 6d0b2dce15..361bf0f8fa 100644--- a/docs/localization-pt-br.md+++ b/docs/localization-pt-br.md@@ -353,13 +353,9 @@ the whole catalog in the same change.When English copy changes, `pnpm i18n:check` marks the old translation stale.Re-translate it from the new English instead of re-accepting it unchanged.-The pt-BR pack is kept complete. `pnpm i18n:check` fails when `pt-br.json`-misses an English key or holds a value identical to the English one, so a-missing translation can't hide behind the English fallback. Values with no-words outside placeholders, such as `{reason}`, pass. `node-scripts/generate-locale.mjs pt-br` drafts missing and stale keys. When a value-rightly stays English (a name, a code, or a word both languages share, such as-“Claude”, “CSV” or “Terminal”), add it as one line to `sameAsEnglish` under-`pt-br` in `scripts/complete-locales.json`. Otherwise translate it and accept it-as above. Drafts for pt-BR ask the model for `IA` and the core terms of this-glossary, but still check each one against it.+Like every other pack, pt-BR may lag behind English: a missing key reads in+English until it is translated, and `pnpm i18n:check` doesn't fail on it. To+catch up, `node scripts/generate-locale.mjs pt-br` drafts missing and stale+keys; translate or review them and accept them as above. Drafts for pt-BR ask+the model for `IA` and the core terms of this glossary, but still check each+one against it.diff --git a/docs/localization.md b/docs/localization.mdindex 953078e85f..6223e7faf5 100644--- a/docs/localization.md+++ b/docs/localization.md@@ -19,9 +19,8 @@ Follow the language's style guide and glossary when one exists: [Brazilian Portuempty entries, locale filename casing, placeholder parity, and the Englishsource hash recorded for each translated value. If English copy changes afterits hash was recorded, the old translation fails the check instead of silently-looking current. Missing translations remain allowed because the runtime has-an English fallback,-except in packs listed in `scripts/complete-locales.json` (today only pt-BR).+looking current. Missing translations are allowed in every language, because the+runtime falls back to English; no pack is held to being complete.## Source hashes are recorded at releasediff --git a/scripts/complete-locales.json b/scripts/complete-locales.jsondeleted file mode 100644index d7f0e22139..0000000000--- a/scripts/complete-locales.json+++ /dev/null@@ -1,123 +0,0 @@-{- "pt-br": {- "sameAsEnglish": [- "{bytes} / {limit} bytes",- "{count} bot",- "{count} bots",- "{count} bytes",- "{count} KB",- "{count} logins",- "{count} logins · {who}",- "{count} MB",- "{count} scripts",- "{hours} h",- "{minutes} min",- "{tokens} tok",- "~{count} min",- "1 bot",- "1 login",- "1 script",- "1Password",- "2FA",- "accounts.example.com",- "Admin",- "Android",- "App",- "App: {title}",- "Apple Pay",- "Apps",- "Auto",- "Auto (Jev)",- "Avatar",- "Azure OpenAI",- "Backups",- "Base: {image}",- "Beta · Ubuntu 24.04 GNOME/{session} · Cua Driver 0.19.3",- "Boat",- "Bot",- "Bots",- "Bots: {count}",- "Cerebras Cloud",- "ChatGPT",- "Chatterbox",- "Chatterbox (local)",- "Claude",- "Claude Code",- "Claude Desktop",- "Cloud",- "Codex",- "Commit {id}",- "coral",- "Coral",- "Cron {expression}",- "CSV",- "Ctrl–Alt–Del",- "Cursor",- "DeepSeek Harness",- "Design",- "desktop",- "Desktop",- "Desktops",- "ElevenLabs",- "Esc",- "Excel (XLSX)",- "Experimental",- "Fish Audio",- "Full HD · 1920×1080",- "G Pay",- "Gemini CLI",- "github.com/owner/repo",- "Grok",- "Grok (xAI)",- "Halloween",- "HighLevel",- "Host · {provider}",- "Host · Grok",- "Inter",- "iPhone",- "Issue {id}",- "Link",- "LM Studio (Bionic)",- "Local",- "Logins",- "Mac",- "Manual",- "Marketing",- "Marketplace",- "MausBot Cloud",- "MausBot Cloud Pro",- "Meta Model API",- "MiB",- "My Cloud",- "my-vps",- "null",- "OK",- "OpenAI",- "OpenRouter",- "Parquet",- "Playbooks",- "Playbooks: {names}",- "Plugins",- "Poppins",- "Pull request {id}",- "Slack",- "SQL",- "Status",- "Tab",- "Tablet · 820×1180",- "Terminal",- "Token",- "Tokens",- "TypeSafe Jev",- "Ubuntu on Xorg",- "USB",- "v{n}",- "Webhook",- "Webhooks",- "Wi-Fi",- "X (Twitter)",- "x.ai/bot/…",- "Zoom"- ]- }-}diff --git a/scripts/generate-locale.mjs b/scripts/generate-locale.mjsindex d834deb4bf..f5c93e2c1b 100644--- a/scripts/generate-locale.mjs+++ b/scripts/generate-locale.mjs@@ -25,8 +25,6 @@ const SCRIPT_PATH = fileURLToPath(import.meta.url);const LOCALES_DIR = join(dirname(SCRIPT_PATH), "..", "src", "locales");const SOURCE_FILE = "en.json";const SOURCE_HASH_FILE = "source-hashes.json";-const COMPLETE_LOCALES_FILE = "complete-locales.json";-const COMPLETE_LOCALES_PATH = join(dirname(SCRIPT_PATH), COMPLETE_LOCALES_FILE);const LOCALE_CODE = /^[a-z]{2,3}(?:-[a-z0-9]{2,8})*$/;const PLACEHOLDER = /\{(\w+)\}/g;const MODEL_TIMEOUT_MS = 5 * 60 * 1_000;@@ -71,18 +69,13 @@ export function validateSourceCatalog(source) {return problems;}-function hasWords(value) {- return /\p{L}/u.test(String(value).replace(PLACEHOLDER, ""));-}-export function validateTranslationCatalog(source,translation,- { requireComplete = false, sameAsEnglish = undefined } = {},+ { requireComplete = false } = {},) {if (!isRecord(translation)) return ["translation must be a JSON object"];const problems = [];- const keptEnglish = sameAsEnglish === undefined ? null : new Set(sameAsEnglish);for (const [key, value] of Object.entries(translation)) {if (!Object.hasOwn(source, key)) {problems.push(`${key}: key does not exist in English`);@@ -97,9 +90,6 @@ export function validateTranslationCatalog(if (!sameStrings(expected, actual)) {problems.push(`${key}: placeholders must stay ${JSON.stringify(expected)} (received ${JSON.stringify(actual)})`);}- if (keptEnglish && value === source[key] && hasWords(value) && !keptEnglish.has(value)) {- problems.push(`${key}: same as English (${JSON.stringify(value)})`);- }}if (requireComplete) {for (const key of Object.keys(source)) {@@ -169,28 +159,6 @@ function emptySourceHashes() {return { version: 1, locales: {} };}-function readCompleteLocales(path) {- const value = readJson(path, COMPLETE_LOCALES_FILE);- if (!isRecord(value)) throw new Error(`${COMPLETE_LOCALES_FILE}: expected { "<locale>": { "sameAsEnglish": [ ... ] } }`);- for (const [code, rules] of Object.entries(value)) {- const valid = normalizeLocaleCode(code) === code- && code !== "en"- && isRecord(rules)- && Array.isArray(rules.sameAsEnglish)- && rules.sameAsEnglish.every((entry) => typeof entry === "string" && entry.trim());- if (!valid) throw new Error(`${COMPLETE_LOCALES_FILE}: invalid locale entry ${code}`);- }- return value;-}--function completeLocaleHelp(code) {- return [- `${code}.json must stay complete. For each ${code}.json line above:`,- ` - missing or stale: run "node scripts/generate-locale.mjs ${code}", or translate it by hand and run "node scripts/generate-locale.mjs ${code} --accept";`,- ` - same as English: translate it and run "node scripts/generate-locale.mjs ${code} --accept". If it rightly stays English (a name, a code, a word both languages share), add the value as one line to "sameAsEnglish" under "${code}" in scripts/${COMPLETE_LOCALES_FILE}.`,- ].join("\n");-}-function readSourceHashes(directory = LOCALES_DIR) {const path = join(directory, SOURCE_HASH_FILE);if (!existsSync(path)) return emptySourceHashes();@@ -260,13 +228,10 @@ function catalogFiles(directory) {.sort();}-export function checkCatalogs(directory = LOCALES_DIR, completeLocalesPath = directory === LOCALES_DIR ? COMPLETE_LOCALES_PATH : null) {+export function checkCatalogs(directory = LOCALES_DIR) {const source = readSourceCatalog(directory);const state = readSourceHashes(directory);const errors = [];- const completeLocales = completeLocalesPath ? readCompleteLocales(completeLocalesPath) : {};- const targetCodes = new Set();- const help = [];const sourceKeys = Object.keys(source);const files = catalogFiles(directory);@@ -279,17 +244,13 @@ export function checkCatalogs(directory = LOCALES_DIR, completeLocalesPath = direrrors.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);}if (file === SOURCE_FILE) continue;- targetCodes.add(stem);const catalog = readCatalog(file, directory);- const complete = Object.hasOwn(completeLocales, stem)- ? { requireComplete: true, sameAsEnglish: completeLocales[stem].sameAsEnglish }- : {};+ // Every pack follows the same rule: a key it lacks reads in English.const problems = [- ...validateTranslationCatalog(source, catalog, complete),+ ...validateTranslationCatalog(source, catalog),...validateTranslationHashes(source, catalog, state.locales[stem] ?? {}),];errors.push(...problems.map((problem) => `${file}: ${problem}`));- if (complete.requireComplete && problems.length > 0) help.push(completeLocaleHelp(stem));const translated = isRecord(catalog)? sourceKeys.filter((key) => Object.hasOwn(catalog, key)).length: 0;@@ -297,10 +258,7 @@ export function checkCatalogs(directory = LOCALES_DIR, completeLocalesPath = dirconsole.log(`${file}: ${percent}% (${translated}/${sourceKeys.length})`);}- for (const code of Object.keys(completeLocales)) {- if (!targetCodes.has(code)) errors.push(`${COMPLETE_LOCALES_FILE}: ${code} has no matching locale catalog`);- }- if (errors.length > 0) throw new Error([...errors, ...help].join("\n"));+ if (errors.length > 0) throw new Error(errors.join("\n"));console.log(`locale catalogs valid (${files.length} languages, ${sourceKeys.length} English strings)`);}diff --git a/scripts/generate-locale.test.mjs b/scripts/generate-locale.test.mjsindex f4320408fc..c7d6732504 100644--- a/scripts/generate-locale.test.mjs+++ b/scripts/generate-locale.test.mjs@@ -165,91 +165,29 @@ describe("locale draft validation", () => {});});-describe("complete locale packs", () => {- const source = {- save: "Save",- claude: "Claude",- reason: "{reason}",- when: "≈ {time}",- count: "{count} bots",- };- const translated = {- save: "Salvar",- claude: "Claude",- reason: "{reason}",- when: "≈ {time}",- count: "{count} bots",- };-- it("flags English left in place unless it is listed or has no words outside placeholders", () => {- expect(validateTranslationCatalog(source, translated, {- requireComplete: true,- sameAsEnglish: ["Claude", "{count} bots"],- })).toEqual([]);- expect(validateTranslationCatalog(source, { ...translated, save: "Save" }, {- requireComplete: true,- sameAsEnglish: ["Claude"],- })).toEqual([- 'save: same as English ("Save")',- 'count: same as English ("{count} bots")',- ]);- });+describe("every locale pack", () => {+ const source = { save: "Save", claude: "Claude", count: "{count} bots" };- it("lets partial packs repeat English and skip keys", () => {- expect(validateTranslationCatalog(source, { save: "Save", claude: "Claude" })).toEqual([]);- });-- function writeFixture({ portuguese = translated, sameAsEnglish = ["Claude", "{count} bots"] } = {}) {- const directory = temporaryDirectory();- const locales = join(directory, "locales");- mkdirSync(locales);- const hashes = (catalog) => Object.fromEntries(Object.keys(catalog).map((key) => [key, sourceHash(source[key])]));- const french = { save: "Save" };+ function check(catalogs) {+ const locales = temporaryDirectory();writeFileSync(join(locales, "en.json"), JSON.stringify(source));- writeFileSync(join(locales, "pt-br.json"), JSON.stringify(portuguese));- writeFileSync(join(locales, "fr.json"), JSON.stringify(french));- writeFileSync(join(locales, "source-hashes.json"), JSON.stringify({- version: 1,- locales: { "pt-br": hashes(portuguese), fr: hashes(french) },- }));- const complete = join(directory, "complete-locales.json");- writeFileSync(complete, JSON.stringify({ "pt-br": { sameAsEnglish } }));- return { complete, locales };- }-- function check({ complete, locales }) {+ for (const [code, catalog] of Object.entries(catalogs)) writeFileSync(join(locales, `${code}.json`), JSON.stringify(catalog));+ writeFileSync(join(locales, "source-hashes.json"), JSON.stringify({ version: 1, locales: {} }));const log = vi.spyOn(console, "log").mockImplementation(() => undefined);try {- checkCatalogs(locales, complete);+ checkCatalogs(locales);} finally {log.mockRestore();}}- it("passes a complete pack while partial packs keep their English fallback", () => {- expect(() => check(writeFixture())).not.toThrow();- });-- it("fails --check for a missing key and says how to fill it", () => {- const portuguese = { ...translated };- delete portuguese.save;- expect(() => check(writeFixture({ portuguese }))).toThrow(- /pt-br\.json: save: translation is missing[\s\S]*node scripts\/generate-locale\.mjs pt-br"/,- );- });-- it("fails --check for unlisted English and names the list to extend", () => {- expect(() => check(writeFixture({ sameAsEnglish: ["{count} bots"] }))).toThrow(- /pt-br\.json: claude: same as English \("Claude"\)[\s\S]*"sameAsEnglish" under "pt-br" in scripts\/complete-locales\.json/,- );+ it("may skip keys and repeat English, whichever language it is", () => {+ expect(() => check({ "pt-br": { save: "Salvar" }, fr: { save: "Save", claude: "Claude" } })).not.toThrow();});- it("rejects a malformed list and a list for a pack that does not exist", () => {- const fixture = writeFixture();- writeFileSync(fixture.complete, JSON.stringify({ "pt-br": ["Claude"] }));- expect(() => check(fixture)).toThrow(/complete-locales\.json: invalid locale entry pt-br/);- writeFileSync(fixture.complete, JSON.stringify({ it: { sameAsEnglish: [] } }));- expect(() => check(fixture)).toThrow(/complete-locales\.json: it has no matching locale catalog/);+ it("still fails --check for a broken placeholder in any pack", () => {+ expect(() => check({ "pt-br": { count: "{n} bots" } })).toThrow(/pt-br\.json: count: placeholders must stay/);+ expect(() => check({ fr: { count: "{n} bots" } })).toThrow(/fr\.json: count: placeholders must stay/);});});