Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

chore(i18n): seed the untranslated-literal ratchet before any migration

Juan Deniscb5043d2d7d2
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index d46d6d27..8ff0909e 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -31,9 +31,11 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
+ "i18next": "^26.3.6",
"lucide-react": "^0.363.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
+ "react-i18next": "^17.0.11",
"react-icons": "^5.6.0",
"react-router-dom": "^7.18.1",
"recharts": "^2.12.3",
@@ -49,6 +51,7 @@
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
+ "espree": "^11.2.0",
"globals": "^15.9.0",
"sass": "^1.86.0",
"vite": "^8.1.4"
@@ -58,9 +61,9 @@
}
},
"node_modules/@babel/runtime": {
- "version": "7.28.6",
- "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz",
- "integrity": "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==",
+ "version": "7.29.7",
+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz",
+ "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
@@ -215,6 +218,24 @@
"url": "https://opencollective.com/eslint"
}
},
+ "node_modules/@eslint/eslintrc/node_modules/espree": {
+ "version": "10.4.0",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz",
+ "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "acorn": "^8.15.0",
+ "acorn-jsx": "^5.3.2",
+ "eslint-visitor-keys": "^4.2.1"
+ },
+ "engines": {
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
+ }
+ },
"node_modules/@eslint/eslintrc/node_modules/globals": {
"version": "14.0.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
@@ -2527,9 +2548,9 @@
}
},
"node_modules/acorn": {
- "version": "8.15.0",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
- "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
+ "version": "8.18.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
+ "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
"dev": true,
"license": "MIT",
"bin": {
@@ -3747,7 +3768,7 @@
"url": "https://opencollective.com/eslint"
}
},
- "node_modules/espree": {
+ "node_modules/eslint/node_modules/espree": {
"version": "10.4.0",
"resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz",
"integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==",
@@ -3765,6 +3786,37 @@
"url": "https://opencollective.com/eslint"
}
},
+ "node_modules/espree": {
+ "version": "11.2.0",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-11.2.0.tgz",
+ "integrity": "sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "acorn": "^8.16.0",
+ "acorn-jsx": "^5.3.2",
+ "eslint-visitor-keys": "^5.0.1"
+ },
+ "engines": {
+ "node": "^20.19.0 || ^22.13.0 || >=24"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
+ }
+ },
+ "node_modules/espree/node_modules/eslint-visitor-keys": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz",
+ "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": "^20.19.0 || ^22.13.0 || >=24"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
+ }
+ },
"node_modules/esquery": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz",
@@ -4214,6 +4266,43 @@
"node": ">= 0.4"
}
},
+ "node_modules/html-parse-stringify": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-4.0.1.tgz",
+ "integrity": "sha512-0zHsZJrK7S3K2aucXWL6ycoYJ/iNtIcFHC/nYQgFklPtrv5LpJctIiSCroWZWeuoXvuyFdzp6KzjJQ+OT5MfFw==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://locize.com"
+ }
+ },
+ "node_modules/i18next": {
+ "version": "26.3.6",
+ "resolved": "https://registry.npmjs.org/i18next/-/i18next-26.3.6.tgz",
+ "integrity": "sha512-Bu5Z2nAXgfVyM8xvW3jk9EKRIuX37PudsrBViThNFx7CR7aaYTpP01cxNB/E4c4UUzTDiAZRstEhsRfPOL/8xA==",
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://www.locize.com/i18next"
+ },
+ {
+ "type": "individual",
+ "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project"
+ },
+ {
+ "type": "individual",
+ "url": "https://www.locize.com"
+ }
+ ],
+ "license": "MIT",
+ "peerDependencies": {
+ "typescript": "^5 || ^6 || ^7"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
"node_modules/ignore": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
@@ -5549,6 +5638,33 @@
"react": "^18.3.1"
}
},
+ "node_modules/react-i18next": {
+ "version": "17.0.11",
+ "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-17.0.11.tgz",
+ "integrity": "sha512-cDtkXgxjuFTWUH6V+aQn1Ve5vDiUztCNPWW5GtSHDccsgRXO1nE6QFWCEmc1KAutrb3OUv87wFShJL5RhUwPXg==",
+ "license": "MIT",
+ "dependencies": {
+ "@babel/runtime": "^7.29.2",
+ "html-parse-stringify": "^4.0.1",
+ "use-sync-external-store": "^1.6.0"
+ },
+ "peerDependencies": {
+ "i18next": ">= 26.2.0",
+ "react": ">= 16.8.0",
+ "typescript": "^5 || ^6 || ^7"
+ },
+ "peerDependenciesMeta": {
+ "react-dom": {
+ "optional": true
+ },
+ "react-native": {
+ "optional": true
+ },
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
"node_modules/react-icons": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.6.0.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 80b95e38..820078f8 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -7,9 +7,10 @@
"dev": "vite",
"build": "vite build",
"test": "node --test",
- "lint": "eslint . && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node scripts/check-style-ownership.mjs && node scripts/check-status-one-door.mjs && node scripts/check-status-scss.mjs && node ../scripts/check-html-sinks.mjs",
+ "lint": "eslint . && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node scripts/check-style-ownership.mjs && node scripts/check-status-one-door.mjs && node scripts/check-status-scss.mjs && node scripts/check-i18n-literals.mjs && node ../scripts/check-html-sinks.mjs",
"lint:settings-index": "node scripts/check-settings-index.mjs",
"lint:status": "node scripts/check-status-one-door.mjs",
+ "lint:i18n": "node scripts/check-i18n-literals.mjs",
"lint:html-sinks": "node ../scripts/check-html-sinks.mjs",
"lint:frontend-boundaries": "node scripts/check-frontend-boundaries.mjs",
"capture:skeletons": "node scripts/capture-skeletons.mjs",
@@ -42,9 +43,11 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
+ "i18next": "^26.3.6",
"lucide-react": "^0.363.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
+ "react-i18next": "^17.0.11",
"react-icons": "^5.6.0",
"react-router-dom": "^7.18.1",
"recharts": "^2.12.3",
@@ -60,6 +63,7 @@
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
+ "espree": "^11.2.0",
"globals": "^15.9.0",
"sass": "^1.86.0",
"vite": "^8.1.4"
diff --git a/frontend/scripts/I18N_LITERAL_CEILING b/frontend/scripts/I18N_LITERAL_CEILING
new file mode 100644
index 00000000..432080b5
--- /dev/null
+++ b/frontend/scripts/I18N_LITERAL_CEILING
@@ -0,0 +1 @@
+8225
diff --git a/frontend/scripts/check-i18n-literals.mjs b/frontend/scripts/check-i18n-literals.mjs
new file mode 100644
index 00000000..5fb4bd88
--- /dev/null
+++ b/frontend/scripts/check-i18n-literals.mjs
@@ -0,0 +1,348 @@
+#!/usr/bin/env node
+// Plan 79 D3 ratchet — untranslated user-visible copy.
+//
+// Counts string literals that a user can READ and that are not addressed by a
+// translation key. Four shapes, because copy escapes into all four:
+//
+// 1. JSX text nodes <p>No applications yet</p>
+// 2. JSX copy attributes <Input placeholder="Search apps" />
+// 3. Toast / confirm arguments toast.error('Failed to save')
+// 4. Copy keys in data objects { label: 'Applications' } <- sidebarItems.js
+//
+// Shape 4 is the one that usually escapes an extraction pass: a label sitting
+// in a data file is still copy, and if it is resolved at module load it also
+// never re-renders on a locale switch. It is counted so that converting those
+// files is visible here.
+//
+// A literal is exempt when it is an argument of `t(...)` — that is the whole
+// point of the migration — or when it does not look like prose (see isCopy).
+//
+// This is a ratchet, not a gate: the count may only go down. It is seeded
+// BEFORE the migration starts (plan 76 rule 1: a migration without a ratchet
+// regrows) so that a new page, or plan 68's Recipes surface, cannot add
+// untranslated copy without failing `npm run lint`.
+//
+// Usage (from frontend/):
+// node scripts/check-i18n-literals.mjs # check against the ceiling
+// node scripts/check-i18n-literals.mjs --report # list the worst files
+// node scripts/check-i18n-literals.mjs --report --file src/pages/Apps.jsx
+// node scripts/check-i18n-literals.mjs --update # write the current count
+
+import { readFileSync, readdirSync, writeFileSync } from 'node:fs';
+import { dirname, extname, join, relative, resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { parse } from 'espree';
+
+const here = dirname(fileURLToPath(import.meta.url));
+const root = resolve(here, '..');
+const srcDir = resolve(root, 'src');
+const ceilingFile = resolve(here, 'I18N_LITERAL_CEILING');
+
+// Slack before the ceiling is considered stale. Larger than the style
+// ratchet's 5 because this census starts in the thousands and a single page
+// conversion moves it by dozens; smaller than a wave, so a finished wave still
+// has to write its result down.
+const STALE_SLACK = 50;
+
+// Props whose value is read by a human. `title` is here even though it is
+// sometimes a machine value — the false positives are excluded by isCopy.
+const COPY_PROPS = new Set([
+ 'label', 'placeholder', 'title', 'description', 'helpText', 'help',
+ 'emptyText', 'emptyMessage', 'confirmText', 'cancelText', 'submitText',
+ 'heading', 'subtitle', 'subheading', 'caption', 'hint', 'tooltip',
+ 'alt', 'aria-label', 'aria-description', 'aria-placeholder',
+ 'message', 'text', 'buttonText', 'actionLabel', 'header',
+]);
+
+// Object keys that carry copy in data files (sidebarItems.js, column defs,
+// wizard step tables, validation maps).
+const COPY_KEYS = new Set([
+ 'label', 'title', 'description', 'placeholder', 'helpText', 'help',
+ 'emptyText', 'emptyMessage', 'confirmText', 'cancelText', 'submitText',
+ 'heading', 'subtitle', 'subheading', 'caption', 'hint', 'tooltip',
+ 'message', 'buttonText', 'actionLabel', 'header', 'summary',
+]);
+
+// Callees whose string arguments are shown to a user.
+const COPY_CALLS = new Set([
+ 'success', 'error', 'info', 'warning', 'warn', 'message', 'loading',
+ 'showToast', 'toast', 'notify', 'confirm', 'alert',
+]);
+const TOAST_OBJECTS = new Set(['toast', 'toasts', 'sonner', 'notifications']);
+
+// Directories that hold no user-facing copy, or hold it deliberately.
+const SKIP_DIRS = new Set(['__tests__', '__mocks__', 'node_modules']);
+const SKIP_FILE = /\.(test|spec|stories)\.[jt]sx?$/;
+// The i18n plumbing itself: locale JSON loaders, the manifest, the format
+// door's own fallback strings.
+const SKIP_PATH = /^(i18n\/|data\/bundledThemes)/;
+
+/**
+ * Does this literal read as prose a user would notice?
+ *
+ * Deliberately generous on the exclusion side: a ratchet that flags
+ * `className="btn"` trains people to ignore it. The rule is "contains a space,
+ * or is a capitalised word of 3+ characters" — which keeps "Save" and
+ * "No results found" and drops "sm", "btn-primary", "app_id", "/api/v1/apps".
+ */
+function isCopy(raw) {
+ const value = String(raw).trim();
+ if (value.length < 2) return false;
+ if (!/[A-Za-z]/.test(value)) return false; // numbers, symbols, spacers
+ if (/^https?:\/\//.test(value)) return false; // URLs
+ if (/^[/#.]/.test(value)) return false; // routes, selectors, anchors
+ if (/^[a-z0-9]+([-_.:][a-z0-9]+)+$/.test(value)) return false; // ids, css classes, keys
+ if (/^[A-Z0-9]+(_[A-Z0-9]+)*$/.test(value)) return false; // CONSTANT_CASE
+ if (/^[a-z]+$/.test(value)) return false; // bare lowercase token: 'sm', 'primary'
+ if (/^\{\{.*\}\}$/.test(value)) return false; // interpolation placeholder
+ if (/^[a-z][a-zA-Z0-9]*$/.test(value)) return false; // camelCase identifier
+ return /\s/.test(value) || /^[A-Z].{2,}/.test(value);
+}
+
+function walkFiles(dir) {
+ return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
+ if (entry.isDirectory()) {
+ return SKIP_DIRS.has(entry.name) ? [] : walkFiles(join(dir, entry.name));
+ }
+ const ext = extname(entry.name);
+ if (ext !== '.js' && ext !== '.jsx') return [];
+ if (SKIP_FILE.test(entry.name)) return [];
+ return [join(dir, entry.name)];
+ });
+}
+
+function calleeName(node) {
+ if (!node) return null;
+ if (node.type === 'Identifier') return node.name;
+ if (node.type === 'MemberExpression' && !node.computed) {
+ return node.property?.name ?? null;
+ }
+ return null;
+}
+
+function calleeObject(node) {
+ if (node?.type === 'MemberExpression' && node.object?.type === 'Identifier') {
+ return node.object.name;
+ }
+ return null;
+}
+
+/** Is this a translation call — `t(...)`, `i18n.t(...)`, `props.t(...)`? */
+function isTranslationCall(node) {
+ if (node.type !== 'CallExpression') return false;
+ return calleeName(node.callee) === 't';
+}
+
+function attributeName(attr) {
+ const name = attr.name;
+ if (!name) return null;
+ return name.type === 'JSXNamespacedName'
+ ? `${name.namespace.name}:${name.name.name}`
+ : name.name;
+}
+
+function propertyKey(prop) {
+ if (prop.computed) return null;
+ const key = prop.key;
+ if (!key) return null;
+ return key.type === 'Identifier' ? key.name : (typeof key.value === 'string' ? key.value : null);
+}
+
+/** Every string literal reachable from a node, ignoring nested translation calls. */
+function collectStrings(node, out) {
+ if (!node || typeof node !== 'object') return;
+ if (Array.isArray(node)) {
+ for (const child of node) collectStrings(child, out);
+ return;
+ }
+ if (!node.type) return;
+ if (isTranslationCall(node)) return;
+ if (node.type === 'Literal' && typeof node.value === 'string') {
+ out.push(node);
+ return;
+ }
+ if (node.type === 'TemplateLiteral') {
+ for (const quasi of node.quasis) {
+ if (quasi.value.cooked) out.push({ ...quasi, value: quasi.value.cooked });
+ }
+ for (const expr of node.expressions) collectStrings(expr, out);
+ return;
+ }
+ for (const key of Object.keys(node)) {
+ if (key === 'type' || key === 'loc' || key === 'range' || key === 'parent') continue;
+ collectStrings(node[key], out);
+ }
+}
+
+function censusFile(path, rel) {
+ const source = readFileSync(path, 'utf8');
+ let ast;
+ try {
+ ast = parse(source, {
+ ecmaVersion: 'latest',
+ sourceType: 'module',
+ ecmaFeatures: { jsx: true },
+ loc: true,
+ });
+ } catch (error) {
+ // A file this script cannot parse cannot be censused; failing loudly
+ // beats silently dropping its literals out of the ceiling.
+ throw new Error(`${rel}: parse failed — ${error.message}`);
+ }
+
+ const hits = [];
+ const record = (node, kind, value) => {
+ const text = String(value).trim().replace(/\s+/g, ' ');
+ if (!isCopy(text)) return;
+ hits.push({ line: node.loc?.start.line ?? 0, kind, text: text.slice(0, 70) });
+ };
+
+ const visit = (node) => {
+ if (!node || typeof node !== 'object') return;
+ if (Array.isArray(node)) {
+ for (const child of node) visit(child);
+ return;
+ }
+ if (!node.type) return;
+
+ // 0. Translated already — the literal inside `t('k', 'Default')` is the
+ // source of English, not an untranslated string. Do not descend.
+ if (isTranslationCall(node)) return;
+
+ switch (node.type) {
+ // 1. JSX text nodes.
+ case 'JSXText':
+ record(node, 'text', node.value);
+ break;
+
+ // 2. JSX copy attributes.
+ case 'JSXAttribute': {
+ const name = attributeName(node);
+ if (name && COPY_PROPS.has(name) && node.value) {
+ if (node.value.type === 'Literal' && typeof node.value.value === 'string') {
+ record(node, 'prop', node.value.value);
+ } else if (node.value.type === 'JSXExpressionContainer') {
+ const strings = [];
+ collectStrings(node.value.expression, strings);
+ for (const literal of strings) record(literal, 'prop', literal.value);
+ }
+ // Value handled; keep descending for nested JSX only.
+ if (node.value.type === 'JSXExpressionContainer') break;
+ return;
+ }
+ break;
+ }
+
+ // 3. Toast / confirm arguments.
+ case 'CallExpression': {
+ const name = calleeName(node.callee);
+ const object = calleeObject(node.callee);
+ const isCopyCall = name && COPY_CALLS.has(name)
+ && (object === null || TOAST_OBJECTS.has(object) || name === 'confirm');
+ if (isCopyCall) {
+ for (const arg of node.arguments) {
+ const strings = [];
+ collectStrings(arg, strings);
+ for (const literal of strings) record(literal, 'toast', literal.value);
+ }
+ for (const arg of node.arguments) visit(arg);
+ return;
+ }
+ break;
+ }
+
+ // 4. Copy keys in data objects.
+ case 'Property': {
+ const key = propertyKey(node);
+ if (key && COPY_KEYS.has(key) && node.value?.type === 'Literal'
+ && typeof node.value.value === 'string') {
+ record(node, 'data', node.value.value);
+ return;
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ for (const key of Object.keys(node)) {
+ if (key === 'type' || key === 'loc' || key === 'range' || key === 'parent') continue;
+ visit(node[key]);
+ }
+ };
+
+ visit(ast);
+ return hits;
+}
+
+export function census() {
+ const byFile = new Map();
+ for (const path of walkFiles(srcDir)) {
+ const rel = relative(srcDir, path).replaceAll('\\', '/');
+ if (SKIP_PATH.test(rel)) continue;
+ const hits = censusFile(path, rel);
+ if (hits.length) byFile.set(rel, hits);
+ }
+ return byFile;
+}
+
+const byFile = census();
+const count = [...byFile.values()].reduce((total, hits) => total + hits.length, 0);
+
+if (process.argv.includes('--update')) {
+ writeFileSync(ceilingFile, `${count}\n`);
+ console.log(`i18n literal ceiling updated to ${count}`);
+ process.exit(0);
+}
+
+if (process.argv.includes('--report')) {
+ const fileArg = process.argv[process.argv.indexOf('--file') + 1];
+ if (process.argv.includes('--file') && fileArg) {
+ const key = fileArg.replace(/\\/g, '/').replace(/^(frontend\/)?src\//, '');
+ const hits = byFile.get(key) || [];
+ for (const hit of hits) {
+ console.log(` ${String(hit.line).padStart(5)} ${hit.kind.padEnd(5)} ${hit.text}`);
+ }
+ console.log(`\n${key}: ${hits.length}`);
+ process.exit(0);
+ }
+ const rows = [...byFile].sort((a, b) => b[1].length - a[1].length).slice(0, 40);
+ for (const [file, hits] of rows) {
+ const kinds = hits.reduce((acc, hit) => {
+ acc[hit.kind] = (acc[hit.kind] || 0) + 1;
+ return acc;
+ }, {});
+ const detail = Object.entries(kinds).map(([k, v]) => `${k}:${v}`).join(' ');
+ console.log(` ${String(hits.length).padStart(4)} ${file.padEnd(58)} ${detail}`);
+ }
+ console.log(`\ntotal: ${count} untranslated literals in ${byFile.size} files`);
+ process.exit(0);
+}
+
+const ceiling = Number(readFileSync(ceilingFile, 'utf8').trim());
+
+if (count > ceiling) {
+ const worst = [...byFile].sort((a, b) => b[1].length - a[1].length).slice(0, 5);
+ console.error('\ni18n literal check failed:\n');
+ console.error(` ${count} untranslated user-visible literals; the ceiling is ${ceiling}.`);
+ console.error(' New copy must go through a translation key:\n');
+ console.error(" import { useTranslation } from 'react-i18next';");
+ console.error(' const { t } = useTranslation();');
+ console.error(" <h2>{t('apps.empty.title', 'No applications yet')}</h2>\n");
+ console.error(' The second argument is the English default — it is what `en.json` is');
+ console.error(' generated from, so it is never wrong to include it.\n');
+ for (const [file, hits] of worst) {
+ console.error(` ${String(hits.length).padStart(4)} ${file}`);
+ }
+ console.error('\n node scripts/check-i18n-literals.mjs --report --file <path> to see them\n');
+ process.exit(1);
+}
+
+if (ceiling - count > STALE_SLACK) {
+ console.error(`\ni18n literal ceiling is ${ceiling} but only ${count} remain; run`);
+ console.error(' node scripts/check-i18n-literals.mjs --update\n');
+ process.exit(1);
+}
+
+console.log(`✓ i18n literals: ${count} untranslated literals remain ratcheted (ceiling ${ceiling}).`);