81a93a489b
Backend — Photos timeline now groups by real capture date instead of upload time. New MediaMetadataService (FileLifecycleHook) extracts EXIF DateTimeOriginal from images and container creation_time from videos (mov/mp4/mkv) via nom-exif, timezone-correct (OffsetTimeOriginal), persisting captured_at so the existing media_sort_date trigger takes over. Adds POST /admin/photos/metadata/reextract to backfill existing media. Falls back to upload date when no embedded date exists. Frontend — premium grid cards: combined metadata line (relative date · size, owner avatar when shared), custom selection checkbox with a clear checked state, uniform full-width 4:3 thumbnail tiles independent of filename length, centered file-type icons, and a hit-test fix so checkbox/star/kebab clicks reach the controls (the decorative thumbnail no longer captures pointer events). Notification messages internationalised across all 16 locales. Broader polish: design tokens, a11y/focus-visible states, brand + PWA assets. Chore — bump semver-compatible dependencies (cargo upgrade); add nom-exif 3.6.1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
56 lines
2.2 KiB
JavaScript
56 lines
2.2 KiB
JavaScript
#!/usr/bin/env node
|
|
// Locale completeness + placeholder-integrity check.
|
|
//
|
|
// Fails (exit 1) if any locale is missing keys present in en.json, has stray
|
|
// extra keys, or if a translated string's {placeholders} differ from the
|
|
// English source. Wire into CI / pre-commit alongside the other linters.
|
|
//
|
|
// node scripts/check-locales.mjs
|
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
import { join, dirname } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const localesDir = join(dirname(fileURLToPath(import.meta.url)), '..', 'static', 'locales');
|
|
|
|
/** Flatten a nested translation object to dotted keys. */
|
|
function flat(obj, prefix = '', out = {}) {
|
|
for (const [k, v] of Object.entries(obj)) {
|
|
const key = prefix ? `${prefix}.${k}` : k;
|
|
if (v && typeof v === 'object' && !Array.isArray(v)) flat(v, key, out);
|
|
else out[key] = v;
|
|
}
|
|
return out;
|
|
}
|
|
|
|
const placeholders = (s) => (typeof s === 'string' ? (s.match(/\{[^}]+\}/g) || []).sort() : []);
|
|
|
|
const en = flat(JSON.parse(readFileSync(join(localesDir, 'en.json'), 'utf8')));
|
|
const enKeys = Object.keys(en);
|
|
let problems = 0;
|
|
|
|
for (const file of readdirSync(localesDir).filter((f) => f.endsWith('.json') && f !== 'en.json')) {
|
|
const loc = flat(JSON.parse(readFileSync(join(localesDir, file), 'utf8')));
|
|
const missing = enKeys.filter((k) => !(k in loc));
|
|
const extra = Object.keys(loc).filter((k) => !(k in en));
|
|
const badPh = enKeys.filter(
|
|
(k) => k in loc && placeholders(en[k]).join() !== placeholders(loc[k]).join()
|
|
);
|
|
if (missing.length || extra.length || badPh.length) {
|
|
problems++;
|
|
console.error(`\n${file}:`);
|
|
if (missing.length)
|
|
console.error(
|
|
` missing ${missing.length}: ${missing.slice(0, 8).join(', ')}${missing.length > 8 ? ' …' : ''}`
|
|
);
|
|
if (extra.length) console.error(` extra ${extra.length}: ${extra.slice(0, 8).join(', ')}`);
|
|
if (badPh.length)
|
|
console.error(` placeholder mismatch ${badPh.length}: ${badPh.slice(0, 8).join(', ')}`);
|
|
}
|
|
}
|
|
|
|
if (problems) {
|
|
console.error(`\n✖ ${problems} locale file(s) have issues.`);
|
|
process.exit(1);
|
|
}
|
|
console.log('✓ All locales complete and placeholder-consistent.');
|