Files
cv/scripts/validate-content.ts
T
dong.nguyen e6b4d83084 refactor(i18n): split content into structure JSON and per-language dictionaries
Phase 1 of spec-v4-live-edit: data/i18n foundation, no visible feature.

- src/data/{profile,skills,experience,projects}.json: language-neutral
  structure documents with thin typed loaders; all prose moved to
  src/i18n/locales/{vi,en}/content.json; chrome strings to ui.json
- src/i18n/: dict-types, cross-document validator (runs at module load and
  via pnpm validate:content), loader joining structure+text once (UI/CONTENT),
  I18nProvider/useI18n mounted in App under LanguageProvider
- all 22 consumers read joined records via useI18n(); field.ts and
  strings.ts deleted; *En field pairs removed from the domain types
- hero tagline renders as plain-text segments (D9); philosophy quotes as
  paragraph arrays; footer display name now localizes per language (D6)
- resume generator consumes UI/CONTENT; generated resume HTML verified
  byte-identical (EN+VI) before/after the migration
- AGENTS.md and v3/v3-i18n + v4 specs updated; deploy.yml concurrency group
2026-10-22 07:29:06 +07:00

30 lines
1.1 KiB
TypeScript

// CLI over the shared validator (spec-v4 §3.6): the CI build gate and, from
// Phase 3 on, the save gate. A malformed content document fails here with
// exact document paths, so the last good deploy stays live.
import { experiences } from '../src/data/experience';
import { profile } from '../src/data/profile';
import { projects } from '../src/data/projects';
import { skillGroups } from '../src/data/skills';
import contentEnJson from '../src/i18n/locales/en/content.json';
import contentViJson from '../src/i18n/locales/vi/content.json';
import type { ContentEn, ContentVi } from '../src/i18n/dict-types';
import { collectContentIssues } from '../src/i18n/validate';
const contentVi: ContentVi = contentViJson;
const contentEn: ContentEn = contentEnJson;
const issues = collectContentIssues(
{ profile, skills: skillGroups, experience: experiences, projects },
contentVi,
contentEn,
);
if (issues.length > 0) {
console.error(`content validation failed (${issues.length} issue(s)):`);
for (const issue of issues) {
console.error(` ${issue.path}: ${issue.message}`);
}
process.exit(1);
}
console.log('content documents valid');