making WEB

Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-11 00:47:52 +03:00
commit 9574aa8a23
87 files changed
+14884

No files matched your search

+117
View File
@@ -0,0 +1,117 @@
#!/usr/bin/env node
// Diffs the Russian catalog (src/i18n/ru.ts) against every t('…') / tf('…')
// literal in src/**/*.ts{,x}, both ways:
// - missing: used in code but absent from ru.ts (falls back to English)
// - orphaned: present in ru.ts but never used as a literal key
//
// Dynamic keys can't be found by this scan and must be checked by hand:
// - watch.ts state strings rendered via t(w.playerEmpty)
// - SHORTCUTS labels (lib/shortcuts.ts) rendered via t(sc.label)
// - HEADS view titles/subtitles (App.tsx) rendered via t(title)/t(sub)
// - server-sent watch.denied reasons (grep sendDenied in
// EchoionWeb/src/WatchSession.cpp) rendered via t(msg.reason)
// Orphans reported here may be one of those dynamic keys — the KNOWN_DYNAMIC
// list below suppresses the ones we know about.
//
// Usage: npm run i18n:check (exits 1 when keys are missing)
import { readFileSync, readdirSync, statSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
const srcDir = join(root, 'src');
const ruFile = join(srcDir, 'i18n', 'ru.ts');
// Keys reached through variables (see header); keep in sync by hand.
const KNOWN_DYNAMIC = new Set([
// watch.ts playerEmpty / state strings
'Nothing loaded — paste a URL above',
'Twitch embeds require HTTPS — open the site via its https:// domain',
// server-sent watch.denied reasons (grep sendDenied in WatchSession.cpp)
'Sign in to control playback',
'Only the host controls playback',
'Watch queue is full',
'Watch queue is empty',
'Live stream — cannot seek',
'That viewer is no longer here',
'Only signed-in viewers can host',
// connection state rendered via t(s.connection) in Sidebar.tsx
'connected',
'disconnected',
'error',
// SHORTCUTS labels (lib/shortcuts.ts)
'Play / pause',
'Seek 5s',
'Volume',
'Skip / vote skip',
'Focus search',
'This help',
// HEADS view titles/subtitles (App.tsx)
'Now Playing',
'What Echoion is streaming to the channel',
'Queue',
'Reorder and manage upcoming tracks',
'Search',
'Find tracks across YouTube and Yandex Music',
'Library',
'Your favorites and saved playlists',
'History & Stats',
'Playback history and server insights',
'Watch Together',
'Synced viewing room — everyone in step',
'Server & Admin',
'Manage subscribers and broadcast',
'RPC / API',
'Connect to Echoion programmatically',
// Sidebar NAV labels rendered via t(item.label) — same strings as HEADS
// titles, listed above.
]);
const unescape = (s) => s.replace(/\\(.)/g, '$1');
function walk(dir, out = []) {
for (const name of readdirSync(dir)) {
const p = join(dir, name);
if (statSync(p).isDirectory()) walk(p, out);
else if (/\.tsx?$/.test(name) && !/\.test\.tsx?$/.test(name)) {
out.push(p);
}
}
return out;
}
// Catalog keys: top-level `'key': '…'` entries of the ru object literal.
const ruKeys = new Set();
for (const m of readFileSync(ruFile, 'utf8').matchAll(
/^\s*'((?:[^'\\]|\\.)*)':/gm
)) {
ruKeys.add(unescape(m[1]));
}
// Used keys: every t('…') / tf('…', …) string literal.
const used = new Set();
for (const file of walk(srcDir)) {
if (file === ruFile) continue;
const text = readFileSync(file, 'utf8');
for (const m of text.matchAll(/\btf?\(\s*'((?:[^'\\]|\\.)*)'/g)) {
used.add(unescape(m[1]));
}
}
const missing = [...used].filter((k) => !ruKeys.has(k)).sort();
const orphaned = [...ruKeys]
.filter((k) => !used.has(k) && !KNOWN_DYNAMIC.has(k))
.sort();
if (missing.length) {
console.log(`Missing from ru.ts (${missing.length}):`);
for (const k of missing) console.log(`\t'${k.replace(/'/g, "\\'")}':`);
}
if (orphaned.length) {
console.log(`\nIn ru.ts but never used as a literal (${orphaned.length}):`);
for (const k of orphaned) console.log(`\t'${k.replace(/'/g, "\\'")}'`);
console.log('(may be dynamic keys — verify before deleting)');
}
if (!missing.length && !orphaned.length) console.log('i18n: OK');
process.exit(missing.length ? 1 : 0);