mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
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
This commit is contained in:
1 parent
f5687cce1c
commit
e6b4d83084
50 files changed
+2215
-961
No files matched your search
@@ -0,0 +1,109 @@
|
||||
// Document types for the content and UI JSON (spec-v4 §3.2–§3.3).
|
||||
// Structure documents are language-neutral; text documents are per language.
|
||||
// Authoring invariants that JSON cannot carry as comments live here and in the
|
||||
// loaders.
|
||||
import type {
|
||||
ExperienceId,
|
||||
PhilosophyId,
|
||||
ProjectCategory,
|
||||
ProjectId,
|
||||
SkillGroupId,
|
||||
} from '../types/index';
|
||||
import uiViJson from './locales/vi/ui.json';
|
||||
|
||||
// --- structure (src/data/*.json) ---
|
||||
|
||||
export type ProjectSectionStructure = {
|
||||
id: string;
|
||||
type: 'text' | 'diagram' | 'metrics' | 'code';
|
||||
};
|
||||
|
||||
export type ProjectStructure = {
|
||||
id: ProjectId;
|
||||
category: ProjectCategory;
|
||||
role: string;
|
||||
technologies: string[];
|
||||
metrics?: string[];
|
||||
featured: boolean;
|
||||
sections: ProjectSectionStructure[];
|
||||
};
|
||||
|
||||
export type ExperienceStructure = {
|
||||
id: ExperienceId;
|
||||
company: string;
|
||||
duration: string;
|
||||
location?: string;
|
||||
variant?: 'current' | 'gap';
|
||||
logo?: string;
|
||||
};
|
||||
|
||||
export type SkillGroupStructure = { id: SkillGroupId; skills: string[] };
|
||||
|
||||
export type ProfileStructure = {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
email: string;
|
||||
githubUrl: string;
|
||||
linkedinUrl: string;
|
||||
githubHandle: string;
|
||||
linkedinHandle: string;
|
||||
telegramUrl: string;
|
||||
telegramHandle: string;
|
||||
currentInterests: string[];
|
||||
roles: string[];
|
||||
// The display name is localized (D6) and therefore lives in the text
|
||||
// documents, never here; only the language-neutral name parts stay.
|
||||
philosophy: Array<{ id: PhilosophyId; keywords: string[] }>;
|
||||
};
|
||||
|
||||
// --- text (src/i18n/locales/{vi,en}/content.json) ---
|
||||
|
||||
// Plain-text segments; markup is a rendering concern (D9), never content.
|
||||
export type TaglineSegment = { text: string; emphasis?: boolean };
|
||||
|
||||
export type SectionText = { title: string; content: string };
|
||||
|
||||
// Section keys are validated against each project's structure array by the
|
||||
// validator (§3.6) — section ids collide across projects, so there is no
|
||||
// global SectionId union (§3.1).
|
||||
export type ProjectText = {
|
||||
title: string;
|
||||
summary: string;
|
||||
sections: Record<string, SectionText>;
|
||||
};
|
||||
|
||||
export type ExperienceText = { title: string; responsibilities: string[] };
|
||||
|
||||
export type SkillGroupText = { title: string };
|
||||
|
||||
export type ProfileText = {
|
||||
name: string;
|
||||
title: string;
|
||||
bio: string;
|
||||
tagline: TaglineSegment[];
|
||||
philosophy: Record<PhilosophyId, { title: string; description: string }>;
|
||||
};
|
||||
|
||||
export type ContentVi = {
|
||||
profile: ProfileText;
|
||||
skills: Record<SkillGroupId, SkillGroupText>;
|
||||
experience: Record<ExperienceId, ExperienceText>;
|
||||
projects: Record<ProjectId, ProjectText>;
|
||||
};
|
||||
|
||||
// Defined here — PartialDeep is NOT a TypeScript builtin.
|
||||
// Objects: every key optional + recursed. Arrays: atomic (whole-array
|
||||
// fallback, never per-item).
|
||||
type PartialDeep<T> = T extends readonly unknown[]
|
||||
? T
|
||||
: T extends object
|
||||
? { [K in keyof T]?: PartialDeep<T[K]> }
|
||||
: T;
|
||||
|
||||
export type ContentEn = { [K in keyof ContentVi]?: PartialDeep<ContentVi[K]> };
|
||||
|
||||
// --- UI (src/i18n/locales/{vi,en}/ui.json) ---
|
||||
|
||||
// Derived from the complete Vietnamese tree; the en import is checked against
|
||||
// this type in index.ts — both files are complete by construction (§3.3).
|
||||
export type UIDict = typeof uiViJson;
|
||||
@@ -1,14 +0,0 @@
|
||||
import type { Language } from '@/types'
|
||||
|
||||
/**
|
||||
* Select one value from a bilingual pair. Plain function, not a hook: `lang` is
|
||||
* read once at component top level with `useLanguage()`, so `field` is safe
|
||||
* inside `.map()` callbacks.
|
||||
*
|
||||
* Convention: `value` is the Vietnamese value, `valueEn` the English one. When a
|
||||
* pair has no English variant yet, `valueEn` is undefined and both languages
|
||||
* render `value`.
|
||||
*/
|
||||
export function field<T>(lang: Language, value: T, valueEn: T | undefined): T {
|
||||
return lang === 'vi' ? value : (valueEn ?? value)
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// The i18n loader (spec-v4 §3.4): load + validate + join ONCE at module load.
|
||||
// Components and scripts consume the exported UI / CONTENT and never join
|
||||
// structure and text by id themselves.
|
||||
import { experiences } from '../data/experience';
|
||||
import { profile } from '../data/profile';
|
||||
import { projects } from '../data/projects';
|
||||
import { skillGroups } from '../data/skills';
|
||||
import contentEnJson from './locales/en/content.json';
|
||||
import contentViJson from './locales/vi/content.json';
|
||||
import uiEnJson from './locales/en/ui.json';
|
||||
import uiViJson from './locales/vi/ui.json';
|
||||
import type {
|
||||
ContentEn,
|
||||
ContentVi,
|
||||
ExperienceStructure,
|
||||
ExperienceText,
|
||||
ProfileStructure,
|
||||
ProfileText,
|
||||
ProjectSectionStructure,
|
||||
ProjectStructure,
|
||||
SectionText,
|
||||
SkillGroupStructure,
|
||||
SkillGroupText,
|
||||
UIDict,
|
||||
} from './dict-types';
|
||||
import type { Language, PhilosophyId } from '../types/index';
|
||||
import { validateContent } from './validate';
|
||||
|
||||
const uiVi: UIDict = uiViJson;
|
||||
// tsc enforces en completeness against the derived Vietnamese tree (§3.3).
|
||||
const uiEn: UIDict = uiEnJson;
|
||||
|
||||
const contentVi: ContentVi = contentViJson;
|
||||
const contentEn: ContentEn = contentEnJson;
|
||||
|
||||
const structures = {
|
||||
profile,
|
||||
skills: skillGroups,
|
||||
experience: experiences,
|
||||
projects,
|
||||
};
|
||||
|
||||
// Cross-document rules run at module load: a malformed content document fails
|
||||
// the build here, in CI, and in the browser — never silently half-renders.
|
||||
validateContent(structures, contentVi, contentEn);
|
||||
|
||||
// Missing en fields fall back to vi per field; arrays are atomic — a whole
|
||||
// array is replaced or inherited, never merged item by item (§3.2).
|
||||
function deepMerge<T>(base: T, patch: unknown): T {
|
||||
if (patch === undefined) return base;
|
||||
if (
|
||||
Array.isArray(base) ||
|
||||
Array.isArray(patch) ||
|
||||
typeof base !== 'object' ||
|
||||
base === null ||
|
||||
typeof patch !== 'object' ||
|
||||
patch === null
|
||||
) {
|
||||
return patch as T;
|
||||
}
|
||||
const out: Record<string, unknown> = { ...(base as Record<string, unknown>) };
|
||||
for (const [key, value] of Object.entries(patch as Record<string, unknown>)) {
|
||||
out[key] = deepMerge(out[key], value);
|
||||
}
|
||||
return out as T;
|
||||
}
|
||||
|
||||
const mergedEn: ContentVi = deepMerge(contentVi, contentEn);
|
||||
|
||||
export const UI: Record<Language, UIDict> = { vi: uiVi, en: uiEn };
|
||||
|
||||
// Resolved records: structure joined with text. These are the shapes every
|
||||
// component consumes.
|
||||
export type ResolvedProjectSection = ProjectSectionStructure & SectionText;
|
||||
export type ResolvedProject = Omit<ProjectStructure, 'sections'> & {
|
||||
title: string;
|
||||
summary: string;
|
||||
sections: ResolvedProjectSection[];
|
||||
};
|
||||
export type ResolvedExperienceEntry = ExperienceStructure & ExperienceText;
|
||||
export type ResolvedSkillGroup = SkillGroupStructure & SkillGroupText;
|
||||
// Structure carries philosophy as an ordered {id, keywords} array, text as a
|
||||
// Record keyed by id — the join merges them back into one ordered array.
|
||||
export type ResolvedPhilosophyPoint = {
|
||||
id: PhilosophyId;
|
||||
keywords: string[];
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
export type ResolvedProfile = Omit<ProfileStructure, 'philosophy'> &
|
||||
Omit<ProfileText, 'philosophy'> & { philosophy: ResolvedPhilosophyPoint[] };
|
||||
|
||||
export type ResolvedContent = {
|
||||
profile: ResolvedProfile;
|
||||
skillGroups: ResolvedSkillGroup[];
|
||||
experiences: ResolvedExperienceEntry[];
|
||||
projects: ResolvedProject[];
|
||||
};
|
||||
|
||||
function joinContent(text: ContentVi): ResolvedContent {
|
||||
return {
|
||||
profile: {
|
||||
...structures.profile,
|
||||
...text.profile,
|
||||
philosophy: structures.profile.philosophy.map((point) => ({
|
||||
...point,
|
||||
...text.profile.philosophy[point.id],
|
||||
})),
|
||||
},
|
||||
skillGroups: structures.skills.map((group) => ({
|
||||
...group,
|
||||
...text.skills[group.id],
|
||||
})),
|
||||
experiences: structures.experience.map((entry) => ({
|
||||
...entry,
|
||||
...text.experience[entry.id],
|
||||
})),
|
||||
projects: structures.projects.map((project) => {
|
||||
const text_ = text.projects[project.id];
|
||||
return {
|
||||
...project,
|
||||
title: text_.title,
|
||||
summary: text_.summary,
|
||||
sections: project.sections.map((section) => ({
|
||||
...section,
|
||||
...text_.sections[section.id],
|
||||
})),
|
||||
};
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
export const CONTENT: Record<Language, ResolvedContent> = {
|
||||
vi: joinContent(contentVi),
|
||||
en: joinContent(mergedEn),
|
||||
};
|
||||
@@ -0,0 +1,120 @@
|
||||
{
|
||||
"profile": {
|
||||
"name": "Dong Nguyen",
|
||||
"bio": "Senior Software Engineer with experience building distributed systems, logistics technology, and AI/ML applications for real-world problems. Focused on system architecture, integration, and production-grade solutions.",
|
||||
"tagline": [
|
||||
{
|
||||
"text": "Building scalable software systems, intelligent logistics solutions, and practical AI applications."
|
||||
}
|
||||
],
|
||||
"philosophy": {
|
||||
"build-for-the-real-problem": {
|
||||
"title": "Build for the real problem",
|
||||
"description": "Don't start with technology. Start with the problem."
|
||||
},
|
||||
"think-in-systems": {
|
||||
"description": "Care about the overall architecture, not just individual components."
|
||||
},
|
||||
"measure-impact": {
|
||||
"description": "Technical implementation must be tied to measurable outcomes."
|
||||
},
|
||||
"business-domain-knowledge-is-a-key-of-success": {
|
||||
"title": "Business domain knowledge is a key of success",
|
||||
"description": "Don't start with technology. Start with the problem."
|
||||
}
|
||||
}
|
||||
},
|
||||
"experience": {
|
||||
"open-to-work": {
|
||||
"title": "Seeking a New Place",
|
||||
"responsibilities": [
|
||||
"Open to Senior Engineer roles: system architecture, integration platforms, full-stack delivery"
|
||||
]
|
||||
},
|
||||
"relax-gap": {
|
||||
"title": "Relax",
|
||||
"responsibilities": [
|
||||
"Intentional break between roles — recovering the rhythm before the next system"
|
||||
]
|
||||
},
|
||||
"lazada-senior-swe": {
|
||||
"responsibilities": [
|
||||
"System ownership and architecture design for logistics integration systems",
|
||||
"Developed IoT-DWS integration solution deployed across 16 sortations",
|
||||
"Led system maintenance and modernization for production environments",
|
||||
"Applied Computer Vision and ML to solve real-world operational problems",
|
||||
"Scrum Master responsibilities — team achieved Scrum Level L3"
|
||||
]
|
||||
},
|
||||
"nexts-founder": {
|
||||
"title": "CTO & Founder",
|
||||
"responsibilities": [
|
||||
"Developed a solution for autonomous vehicles to collect real-time data from onboard sensors and systems, including LiDAR, cameras, GPS, and CAN bus."
|
||||
]
|
||||
},
|
||||
"sap-senior-swe": {
|
||||
"responsibilities": [
|
||||
"Team leader managing the B1 Integration product"
|
||||
]
|
||||
}
|
||||
},
|
||||
"projects": {
|
||||
"iot-dws-integration": {
|
||||
"title": "IoT-DWS Integration System",
|
||||
"summary": "Designed and deployed an integration system between IoT devices and DWS (Dimensioning Weighing Scanning) machines across 16 sortations.",
|
||||
"sections": {
|
||||
"context": {
|
||||
"content": "Took over and rapidly mastered an IoT-DWS system after the previous responsible team member left the project. Needed to quickly understand the current architecture and continue developing the integration solution."
|
||||
},
|
||||
"problem": {
|
||||
"content": "Needed integration between IoT devices (sensors, cameras) and DWS machines — a complex physical system with multiple different protocols (HMI, FTP, HTTP)."
|
||||
},
|
||||
"solution": {
|
||||
"content": "Designed an HTTP-based integration engine with HMAC security, RocketMQ messaging, and protocol adapters for HMI/FTP/HTTP."
|
||||
},
|
||||
"challenges": {
|
||||
"content": "Multiple different protocols, security requirements (HMAC signature), real-time data processing, production reliability."
|
||||
},
|
||||
"result": {
|
||||
"content": "Solution deployed across 16 sortations, stable in production, supporting 3 protocols (HMI, FTP, HTTP)."
|
||||
}
|
||||
}
|
||||
},
|
||||
"awb-detection": {
|
||||
"summary": "Applied Computer Vision and Machine Learning to automatically detect and OCR shipping labels from camera images on sortation lines.",
|
||||
"sections": {
|
||||
"context": {
|
||||
"content": "Sortation machines capture images of packages as they move on conveyor belts. Need to automatically read AWB (Air Waybill) from images for tracking and sorting."
|
||||
},
|
||||
"problem": {
|
||||
"content": "White label on white package — traditional CV methods are not robust enough. Needed ML-based detection."
|
||||
},
|
||||
"result": {
|
||||
"content": "Model fine-tuned for AWB detection, processing 70,000 images/month. Presented at Tech Talk workshop."
|
||||
}
|
||||
}
|
||||
},
|
||||
"facility-management": {
|
||||
"summary": "Built a digital twin platform for logistics facilities — facility modeling, real-time monitoring, and recommendation system.",
|
||||
"sections": {
|
||||
"vision": {
|
||||
"content": "Transition from manual operations to an Operation Intelligence Platform — collect data, monitor, analyze, recommend, decide."
|
||||
},
|
||||
"result": {
|
||||
"content": "Platform supports facility modeling, real-time visibility, and recommendations for capacity planning."
|
||||
}
|
||||
}
|
||||
},
|
||||
"local-llm-experiments": {
|
||||
"summary": "Technical exploration of running local MoE LLMs with llama.cpp — GPU offloading, VRAM optimization, performance tracing.",
|
||||
"sections": {
|
||||
"exploration": {
|
||||
"content": "Technical exploration of MoE (Mixture of Experts), expert routing, GPU offloading, VRAM optimization, prefill/decode pipeline."
|
||||
},
|
||||
"learnings": {
|
||||
"content": "Understand the system → Measure → Analyze → Optimize. Not about showing off hardware — but demonstrating engineering approach."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"nav": {
|
||||
"home": "Home",
|
||||
"resume": "Get resume",
|
||||
"about": "About",
|
||||
"experience": "Experience",
|
||||
"projects": "Projects",
|
||||
"philosophy": "Philosophy",
|
||||
"contact": "Contact",
|
||||
"palette": "Theme",
|
||||
"paletteAria": "Switch theme color",
|
||||
"menuAria": "Site menu",
|
||||
"openMenu": "Open menu",
|
||||
"closeMenu": "Close menu",
|
||||
"groupMenu": "Menu",
|
||||
"groupAppearance": "Appearance",
|
||||
"themeGroup": "Mode",
|
||||
"themeDark": "Dark",
|
||||
"themeLight": "Light",
|
||||
"langGroup": "Language",
|
||||
"langEn": "English",
|
||||
"langVi": "Tiếng Việt",
|
||||
"langSwitch": "Switch language",
|
||||
"switchTo": "Switch to",
|
||||
"mainNav": "Main navigation",
|
||||
"themeSwitch": "Switch display mode",
|
||||
"themeMode": "Display mode"
|
||||
},
|
||||
"social": {
|
||||
"heading": "Connect",
|
||||
"aria": {
|
||||
"github": "View GitHub profile",
|
||||
"linkedin": "View LinkedIn profile",
|
||||
"email": "Send email",
|
||||
"telegram": "Open Telegram chat"
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"copyright": "All rights reserved",
|
||||
"links": {
|
||||
"home": "Home",
|
||||
"about": "About",
|
||||
"projects": "Projects",
|
||||
"contact": "Contact"
|
||||
}
|
||||
},
|
||||
"hero": {
|
||||
"greeting": "Hi, I'm",
|
||||
"ctaProjects": "View Projects",
|
||||
"ctaContact": "Contact Me",
|
||||
"scroll": "Scroll"
|
||||
},
|
||||
"about": {
|
||||
"heading": "About Me",
|
||||
"subtitle": "Senior Software Engineer with deep expertise in distributed systems, logistics technology, and practical AI applications.",
|
||||
"engineeringTitle": "How I Think About Engineering",
|
||||
"exploringTitle": "What I'm Exploring",
|
||||
"exploringTitlePage": "What I'm Currently Exploring",
|
||||
"expertise": "Core Expertise"
|
||||
},
|
||||
"expertise": {
|
||||
"heading": "Core Expertise"
|
||||
},
|
||||
"experience": {
|
||||
"heading": "Experience",
|
||||
"tldr": "TL;DR",
|
||||
"tldrText": "15 years of experience, more than 8 companies along the way. Too long to tell."
|
||||
},
|
||||
"projects": {
|
||||
"featured": "Featured Projects",
|
||||
"all": "Projects",
|
||||
"viewAll": "View All",
|
||||
"viewDetails": "View Details",
|
||||
"categories": {
|
||||
"software-engineering": "Software Engineering",
|
||||
"logistics": "Logistics",
|
||||
"ai-ml": "AI / ML",
|
||||
"computer-vision": "Computer Vision",
|
||||
"architecture": "Architecture",
|
||||
"experiment": "Experiment"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"heading": "Contact",
|
||||
"email": "Email",
|
||||
"github": "GitHub",
|
||||
"linkedin": "LinkedIn",
|
||||
"telegram": "Telegram"
|
||||
},
|
||||
"projectDetail": {
|
||||
"notFound": "Project Not Found",
|
||||
"backToProjects": "Back to Projects",
|
||||
"impact": "Impact",
|
||||
"role": "Role",
|
||||
"technologies": "Technologies",
|
||||
"experiments": "Engineering Experiments"
|
||||
},
|
||||
"philosophy": {
|
||||
"heading": "Philosophy",
|
||||
"quotes": [
|
||||
{
|
||||
"title": "Time is priceless",
|
||||
"details": [
|
||||
"Time is priceless. You can’t buy it, pause it, or rewind it. Once it’s gone, it’s gone for good.",
|
||||
"We spend so much of our lives chasing things—money, status, validation—but time is the one thing we can never earn back.",
|
||||
"So be mindful of how you use it. Invest it in what truly matters: the people you love, the goals that inspire you, the moments that feed your soul."
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"common": {
|
||||
"resumeDownload": "Get Resume",
|
||||
"resumeModalTitle": "Get Resume",
|
||||
"resumeModalAria": "Choose resume language",
|
||||
"resumeModalHint": "Choose a language — the PDF downloads to your device.",
|
||||
"resumeModalClose": "Close resume options",
|
||||
"backToTop": "Scroll to top",
|
||||
"contactTag": "Contact",
|
||||
"experienceTag": "Experience"
|
||||
},
|
||||
"resume": {
|
||||
"EXPERIENCE": "Experience",
|
||||
"SKILLS": "Skills",
|
||||
"PROJECTS": "Projects",
|
||||
"UPDATED": "Last updated",
|
||||
"QR_ALT": "QR code"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
{
|
||||
"profile": {
|
||||
"name": "Nguyễn Đông",
|
||||
"title": "Senior Software Engineer",
|
||||
"bio": "Senior Software Engineer với kinh nghiệm xây dựng hệ thống phân tán, logistics technology, và ứng dụng AI/ML vào bài toán thực tế. Tập trung vào system architecture, integration, và production-grade solutions.",
|
||||
"tagline": [
|
||||
{
|
||||
"text": "Phần lớn thời gian tôi là Backend Software Engineer. Muốn tôi là Full Stack Developer, "
|
||||
},
|
||||
{
|
||||
"text": "yes",
|
||||
"emphasis": true
|
||||
},
|
||||
{
|
||||
"text": ", có thể."
|
||||
}
|
||||
],
|
||||
"philosophy": {
|
||||
"build-for-the-real-problem": {
|
||||
"title": "Giải pháp được xây dựng dựa trên vấn đề thực tế",
|
||||
"description": "Không bắt đầu bằng technology. Bắt đầu bằng problem."
|
||||
},
|
||||
"think-in-systems": {
|
||||
"title": "Think in systems",
|
||||
"description": "Quan tâm đến kiến trúc tổng thể, không chỉ từng component."
|
||||
},
|
||||
"measure-impact": {
|
||||
"title": "Measure impact",
|
||||
"description": "Technical implementation phải gắn với measurable outcome."
|
||||
},
|
||||
"keep-learning": {
|
||||
"title": "Keep learning",
|
||||
"description": "Continuous exploration of new technologies and approaches."
|
||||
},
|
||||
"business-domain-knowledge-is-a-key-of-success": {
|
||||
"title": "Kiến thức nghiệp vụ là chìa khóa thành công",
|
||||
"description": "Hiểu sâu về business domain giúp hiểu rõ vấn đề và đưa ra giải pháp phù hợp."
|
||||
}
|
||||
}
|
||||
},
|
||||
"skills": {
|
||||
"software-engineering": {
|
||||
"title": "Software Engineering"
|
||||
},
|
||||
"system-architecture": {
|
||||
"title": "System Architecture"
|
||||
},
|
||||
"logistics-technology": {
|
||||
"title": "Logistics Technology"
|
||||
},
|
||||
"ai-ml": {
|
||||
"title": "AI / ML"
|
||||
},
|
||||
"infrastructure": {
|
||||
"title": "Infrastructure"
|
||||
},
|
||||
"engineering-practices": {
|
||||
"title": "Engineering Practices"
|
||||
}
|
||||
},
|
||||
"experience": {
|
||||
"open-to-work": {
|
||||
"title": "Đang tìm nơi làm việc mới",
|
||||
"responsibilities": [
|
||||
"Sẵn sàng cho vai trò Senior Engineer: system architecture, integration platform, full-stack delivery"
|
||||
]
|
||||
},
|
||||
"relax-gap": {
|
||||
"title": "Nghỉ ngơi",
|
||||
"responsibilities": [
|
||||
"Nghỉ có chủ đích giữa hai vai trò — lấy lại nhịp trước khi nhận hệ thống tiếp theo",
|
||||
"Tự thử nghiệm theo nhịp riêng: local LLM với llama.cpp, đọc về Computer Vision"
|
||||
]
|
||||
},
|
||||
"lazada-senior-swe": {
|
||||
"title": "Senior Software Engineer",
|
||||
"responsibilities": [
|
||||
"System ownership và architecture design cho logistics integration systems",
|
||||
"Developed IoT-DWS integration solution deployed across 16 sortations",
|
||||
"Led system maintenance and modernization for production environments",
|
||||
"Applied Computer Vision and ML to solve real-world operational problems",
|
||||
"Scrum Master responsibilities — team achieved Scrum Level L3"
|
||||
]
|
||||
},
|
||||
"nexts-founder": {
|
||||
"title": "Người sáng lập",
|
||||
"responsibilities": [
|
||||
"Phát triển giải pháp cho xe tự hành, thu thập dữ liệu thời gian thực từ cảm biến và hệ thống onboard: LiDAR, camera, GPS, CAN bus."
|
||||
]
|
||||
},
|
||||
"sap-senior-swe": {
|
||||
"title": "Senior Software Engineer",
|
||||
"responsibilities": [
|
||||
"Team leader quản lý sản phẩm B1 Integration"
|
||||
]
|
||||
}
|
||||
},
|
||||
"projects": {
|
||||
"iot-dws-integration": {
|
||||
"title": "Tích hợp hệ thống IoT-DWS",
|
||||
"summary": "Thiết kế và triển khai hệ thống integration giữa IoT devices và DWS (Dimensioning Weighing Scanning) machines cho 16 sortations.",
|
||||
"sections": {
|
||||
"context": {
|
||||
"title": "Context",
|
||||
"content": "Tiếp nhận và nhanh chóng làm chủ một hệ thống IoT-DWS sau khi thành viên phụ trách trước đó rời project. Cần hiểu nhanh architecture hiện tại và tiếp tục phát triển integration solution."
|
||||
},
|
||||
"problem": {
|
||||
"title": "Problem",
|
||||
"content": "Cần integration giữa các IoT devices (sensors, cameras) và DWS machines — hệ thống vật lý phức tạp với nhiều protocol khác nhau (HMI, FTP, HTTP)."
|
||||
},
|
||||
"solution": {
|
||||
"title": "Solution",
|
||||
"content": "Thiết kế HTTP-based integration engine với HMAC security, RocketMQ messaging, và protocol adapters cho HMI/FTP/HTTP."
|
||||
},
|
||||
"architecture": {
|
||||
"title": "Architecture",
|
||||
"content": "```text\nIoT Devices\n ↓\nProtocol Adapters (HMI/FTP/HTTP)\n ↓\nHTTP Engine + HMAC Security\n ↓\nRocketMQ\n ↓\nDWS Machines\n```"
|
||||
},
|
||||
"challenges": {
|
||||
"title": "Challenges",
|
||||
"content": "Nhiều protocol khác nhau, security requirements (HMAC signature), real-time data processing, production reliability."
|
||||
},
|
||||
"result": {
|
||||
"title": "Result",
|
||||
"content": "Giải pháp được triển khai cho 16 sortations, ổn định trong production, hỗ trợ 3 protocols (HMI, FTP, HTTP)."
|
||||
}
|
||||
}
|
||||
},
|
||||
"awb-detection": {
|
||||
"title": "AWB Detection / Computer Vision",
|
||||
"summary": "Ứng dụng Computer Vision và Machine Learning để tự động phát hiện và OCR shipping label từ hình ảnh camera trên sortation.",
|
||||
"sections": {
|
||||
"context": {
|
||||
"title": "Context",
|
||||
"content": "Sortation machines chụp ảnh packages khi di chuyển trên băng chuyền. Cần tự động đọc AWB (Air Waybill) từ ảnh để tracking và sorting."
|
||||
},
|
||||
"problem": {
|
||||
"title": "Problem",
|
||||
"content": "White label trên white package — traditional CV methods không đủ robust. Cần ML-based detection."
|
||||
},
|
||||
"pipeline": {
|
||||
"title": "Pipeline",
|
||||
"content": "```text\nImage\n ↓\nAWB/Label Detection (YOLO)\n ↓\nBounding Box / OBB\n ↓\nRotation Correction\n ↓\nCrop\n ↓\nOCR\n ↓\nText Extraction\n```"
|
||||
},
|
||||
"challenges": {
|
||||
"title": "Challenges",
|
||||
"content": "White label on white package, rotated labels, varying lighting conditions, real-time inference requirements."
|
||||
},
|
||||
"result": {
|
||||
"title": "Result",
|
||||
"content": "Model fine-tuned cho AWB detection, xử lý 70,000 images/month. Presentation tại Tech Talk workshop."
|
||||
}
|
||||
}
|
||||
},
|
||||
"facility-management": {
|
||||
"title": "Facility Management Platform",
|
||||
"summary": "Xây dựng nền tảng digital twin cho logistics facilities — mô hình hóa facility, theo dõi real-time, và recommendation system.",
|
||||
"sections": {
|
||||
"vision": {
|
||||
"title": "Vision",
|
||||
"content": "Chuyển đổi từ manual operations sang Operation Intelligence Platform — thu thập data, monitor, analyze, recommend, decide."
|
||||
},
|
||||
"architecture": {
|
||||
"title": "Architecture",
|
||||
"content": "```text\nPhysical Facility\n ↓\nData Collection\n ↓\nFacility Model\n ↓\nDigital Twin\n ↓\nSimulation\n ↓\nAnalytics\n ↓\nRecommendation\n ↓\nOperation Decision\n```"
|
||||
},
|
||||
"result": {
|
||||
"title": "Result",
|
||||
"content": "Platform hỗ trợ facility modeling, real-time visibility, và recommendation cho capacity planning."
|
||||
}
|
||||
}
|
||||
},
|
||||
"local-llm-experiments": {
|
||||
"title": "Local LLM Experiments",
|
||||
"summary": "Technical exploration về running local MoE LLMs với llama.cpp — GPU offloading, VRAM optimization, performance tracing.",
|
||||
"sections": {
|
||||
"exploration": {
|
||||
"title": "Exploration",
|
||||
"content": "Technical exploration về MoE (Mixture of Experts), expert routing, GPU offloading, VRAM optimization, prefill/decode pipeline."
|
||||
},
|
||||
"learnings": {
|
||||
"title": "Lessons Learned",
|
||||
"content": "Understand the system → Measure → Analyze → Optimize. Không phải khoe hardware — mà thể hiện engineering approach."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"nav": {
|
||||
"home": "Trang chủ",
|
||||
"resume": "Tải CV",
|
||||
"about": "Giới thiệu",
|
||||
"experience": "Kinh nghiệm",
|
||||
"projects": "Dự án",
|
||||
"philosophy": "Triết lý",
|
||||
"contact": "Liên hệ",
|
||||
"palette": "Giao diện",
|
||||
"paletteAria": "Đổi màu giao diện",
|
||||
"menuAria": "Menu trang",
|
||||
"openMenu": "Mở menu",
|
||||
"closeMenu": "Đóng menu",
|
||||
"groupMenu": "Menu",
|
||||
"groupAppearance": "Giao diện",
|
||||
"themeGroup": "Chế độ",
|
||||
"themeDark": "Tối",
|
||||
"themeLight": "Sáng",
|
||||
"langGroup": "Ngôn ngữ",
|
||||
"langEn": "English",
|
||||
"langVi": "Tiếng Việt",
|
||||
"langSwitch": "Đổi ngôn ngữ",
|
||||
"switchTo": "Chuyển sang",
|
||||
"mainNav": "Điều hướng chính",
|
||||
"themeSwitch": "Đổi chế độ hiển thị",
|
||||
"themeMode": "Chế độ hiển thị"
|
||||
},
|
||||
"social": {
|
||||
"heading": "Kết nối",
|
||||
"aria": {
|
||||
"github": "Xem hồ sơ GitHub",
|
||||
"linkedin": "Xem hồ sơ LinkedIn",
|
||||
"email": "Gửi email",
|
||||
"telegram": "Mở chat Telegram"
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"copyright": "Bảo lưu mọi quyền",
|
||||
"links": {
|
||||
"home": "Trang chủ",
|
||||
"about": "Giới thiệu",
|
||||
"projects": "Dự án",
|
||||
"contact": "Liên hệ"
|
||||
}
|
||||
},
|
||||
"hero": {
|
||||
"greeting": "Xin chào, tôi là",
|
||||
"ctaProjects": "Xem dự án",
|
||||
"ctaContact": "Liên hệ",
|
||||
"scroll": "Cuộn"
|
||||
},
|
||||
"about": {
|
||||
"heading": "Giới thiệu",
|
||||
"subtitle": "Kỹ sư phần mềm cao cấp với chuyên môn sâu về hệ thống phân tán, công nghệ logistics và ứng dụng AI thực tiễn.",
|
||||
"engineeringTitle": "Cách tôi tư duy về kỹ thuật",
|
||||
"exploringTitle": "Những điều tôi đang tìm hiểu",
|
||||
"exploringTitlePage": "Những điều tôi đang tìm hiểu",
|
||||
"expertise": "Chuyên môn"
|
||||
},
|
||||
"expertise": {
|
||||
"heading": "Chuyên môn"
|
||||
},
|
||||
"experience": {
|
||||
"heading": "Kinh nghiệm",
|
||||
"tldr": "TL;DR",
|
||||
"tldrText": "15 năm kinh nghiệm, hơn 8 công ty đã đi qua. Quá dài để kể hết."
|
||||
},
|
||||
"projects": {
|
||||
"featured": "Dự án nổi bật",
|
||||
"all": "Dự án",
|
||||
"viewAll": "Xem tất cả",
|
||||
"viewDetails": "Xem chi tiết",
|
||||
"categories": {
|
||||
"software-engineering": "Kỹ thuật phần mềm",
|
||||
"logistics": "Logistics",
|
||||
"ai-ml": "AI / ML",
|
||||
"computer-vision": "Computer Vision",
|
||||
"architecture": "Kiến trúc",
|
||||
"experiment": "Thử nghiệm"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"heading": "Liên hệ",
|
||||
"email": "Email",
|
||||
"github": "GitHub",
|
||||
"linkedin": "LinkedIn",
|
||||
"telegram": "Telegram"
|
||||
},
|
||||
"projectDetail": {
|
||||
"notFound": "Không tìm thấy dự án",
|
||||
"backToProjects": "Quay lại dự án",
|
||||
"impact": "Tác động",
|
||||
"role": "Vai trò",
|
||||
"technologies": "Công nghệ",
|
||||
"experiments": "Thí nghiệm kỹ thuật"
|
||||
},
|
||||
"philosophy": {
|
||||
"heading": "Triết lý",
|
||||
"quotes": [
|
||||
{
|
||||
"title": "Thời gian là vô giá",
|
||||
"details": [
|
||||
"Thời gian là vô giá. Bạn không thể mua nó bằng tiền, không thể khiến nó dừng lại, cũng chẳng thể quay ngược về quá khứ. Một khi thời gian đã trôi qua, nó sẽ mãi mãi không trở lại.",
|
||||
"Chúng ta dành quá nhiều thời gian trong cuộc đời để theo đuổi những thứ như tiền bạc, địa vị và sự công nhận từ người khác. Nhưng thời gian là thứ duy nhất mà chúng ta không bao giờ có thể lấy lại.",
|
||||
"Vì vậy, hãy luôn ý thức về cách bạn sử dụng thời gian của mình. Hãy dành thời gian cho những điều thực sự quan trọng: những người bạn yêu thương, những mục tiêu truyền cảm hứng cho bạn và những khoảnh khắc nuôi dưỡng tâm hồn bạn."
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"common": {
|
||||
"resumeDownload": "Tải CV",
|
||||
"resumeModalTitle": "Tải CV",
|
||||
"resumeModalAria": "Chọn ngôn ngữ CV",
|
||||
"resumeModalHint": "Chọn ngôn ngữ — PDF sẽ tải về máy của bạn.",
|
||||
"resumeModalClose": "Đóng tùy chọn tải CV",
|
||||
"backToTop": "Cuộn lên đầu trang",
|
||||
"contactTag": "Liên hệ",
|
||||
"experienceTag": "Kinh nghiệm"
|
||||
},
|
||||
"resume": {
|
||||
"EXPERIENCE": "Kinh nghiệm",
|
||||
"SKILLS": "Kỹ năng",
|
||||
"PROJECTS": "Dự án",
|
||||
"UPDATED": "Cập nhật lần cuối",
|
||||
"QR_ALT": "mã QR"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// I18nProvider / useI18n (spec-v4 §3.5, D3): content and UI strings flow
|
||||
// through one context whose default value is the build-time documents.
|
||||
// Phase 3 overrides this value with draft state; the real components then
|
||||
// render the draft — preview is the production app.
|
||||
import { createContext, useContext } from 'react';
|
||||
import { useLanguage } from '../hooks/useLanguage';
|
||||
import { CONTENT, UI } from './index';
|
||||
import type { ResolvedContent } from './index';
|
||||
import type { UIDict } from './dict-types';
|
||||
import type { Language } from '../types/index';
|
||||
|
||||
export type ResolvedI18n = { ui: UIDict; content: ResolvedContent };
|
||||
|
||||
// Module-level constants: the context value for a given language is the same
|
||||
// object on every render. A value rebuilt per render would re-render every
|
||||
// consumer in the tree on any provider state change.
|
||||
const DEFAULTS: Record<Language, ResolvedI18n> = {
|
||||
en: { ui: UI.en, content: CONTENT.en },
|
||||
vi: { ui: UI.vi, content: CONTENT.vi },
|
||||
};
|
||||
|
||||
const I18nContext = createContext<ResolvedI18n | null>(null);
|
||||
|
||||
export function I18nProvider({
|
||||
children,
|
||||
override,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
override?: ResolvedI18n;
|
||||
}) {
|
||||
const { lang } = useLanguage();
|
||||
return (
|
||||
<I18nContext.Provider value={override ?? DEFAULTS[lang]}>
|
||||
{children}
|
||||
</I18nContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useI18n(): ResolvedI18n {
|
||||
const context = useContext(I18nContext);
|
||||
if (!context) {
|
||||
throw new Error('useI18n must be used within I18nProvider');
|
||||
}
|
||||
return context;
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
export const strings = {
|
||||
nav: {
|
||||
home: {en: 'Home', vi: 'Trang chủ'},
|
||||
resume: {en: 'Get resume', vi: 'Tải CV'},
|
||||
about: {en: 'About', vi: 'Giới thiệu'},
|
||||
experience: {en: 'Experience', vi: 'Kinh nghiệm'},
|
||||
projects: {en: 'Projects', vi: 'Dự án'},
|
||||
philosophy: {en: 'Philosophy', vi: 'Triết lý'},
|
||||
contact: {en: 'Contact', vi: 'Liên hệ'},
|
||||
palette: {en: 'Theme', vi: 'Giao diện'},
|
||||
paletteAria: {en: 'Switch theme color', vi: 'Đổi màu giao diện'},
|
||||
menuAria: {en: 'Site menu', vi: 'Menu trang'},
|
||||
openMenu: {en: 'Open menu', vi: 'Mở menu'},
|
||||
closeMenu: {en: 'Close menu', vi: 'Đóng menu'},
|
||||
groupMenu: {en: 'Menu', vi: 'Menu'},
|
||||
groupAppearance: {en: 'Appearance', vi: 'Giao diện'},
|
||||
themeGroup: {en: 'Mode', vi: 'Chế độ'},
|
||||
themeDark: {en: 'Dark', vi: 'Tối'},
|
||||
themeLight: {en: 'Light', vi: 'Sáng'},
|
||||
langGroup: {en: 'Language', vi: 'Ngôn ngữ'},
|
||||
langEn: {en: 'English', vi: 'English'},
|
||||
langVi: {en: 'Tiếng Việt', vi: 'Tiếng Việt'},
|
||||
langSwitch: {en: 'Switch language', vi: 'Đổi ngôn ngữ'},
|
||||
switchTo: {en: 'Switch to', vi: 'Chuyển sang'},
|
||||
mainNav: {en: 'Main navigation', vi: 'Điều hướng chính'},
|
||||
themeSwitch: {en: 'Switch display mode', vi: 'Đổi chế độ hiển thị'},
|
||||
themeMode: {en: 'Display mode', vi: 'Chế độ hiển thị'},
|
||||
},
|
||||
social: {
|
||||
heading: {en: 'Connect', vi: 'Kết nối'},
|
||||
aria: {
|
||||
github: {en: 'View GitHub profile', vi: 'Xem hồ sơ GitHub'},
|
||||
linkedin: {en: 'View LinkedIn profile', vi: 'Xem hồ sơ LinkedIn'},
|
||||
email: {en: 'Send email', vi: 'Gửi email'},
|
||||
telegram: {en: 'Open Telegram chat', vi: 'Mở chat Telegram'},
|
||||
},
|
||||
},
|
||||
footer: {
|
||||
copyright: {en: 'All rights reserved', vi: 'Bảo lưu mọi quyền'},
|
||||
links: {
|
||||
home: {en: 'Home', vi: 'Trang chủ'},
|
||||
about: {en: 'About', vi: 'Giới thiệu'},
|
||||
projects: {en: 'Projects', vi: 'Dự án'},
|
||||
contact: {en: 'Contact', vi: 'Liên hệ'},
|
||||
},
|
||||
},
|
||||
hero: {
|
||||
greeting: {en: "Hi, I'm", vi: 'Xin chào, tôi là'},
|
||||
ctaProjects: {en: 'View Projects', vi: 'Xem dự án'},
|
||||
ctaContact: {en: 'Contact Me', vi: 'Liên hệ'},
|
||||
scroll: {en: 'Scroll', vi: 'Cuộn'},
|
||||
},
|
||||
about: {
|
||||
heading: {en: 'About Me', vi: 'Giới thiệu'},
|
||||
subtitle: {
|
||||
en: 'Senior Software Engineer with deep expertise in distributed systems, logistics technology, and practical AI applications.',
|
||||
vi: 'Kỹ sư phần mềm cao cấp với chuyên môn sâu về hệ thống phân tán, công nghệ logistics và ứng dụng AI thực tiễn.'
|
||||
},
|
||||
engineeringTitle: {en: 'How I Think About Engineering', vi: 'Cách tôi tư duy về kỹ thuật'},
|
||||
exploringTitle: {en: "What I'm Exploring", vi: 'Những điều tôi đang tìm hiểu'},
|
||||
exploringTitlePage: {en: "What I'm Currently Exploring", vi: 'Những điều tôi đang tìm hiểu'},
|
||||
expertise: {en: 'Core Expertise', vi: 'Chuyên môn'},
|
||||
},
|
||||
expertise: {
|
||||
heading: {en: 'Core Expertise', vi: 'Chuyên môn'},
|
||||
},
|
||||
experience: {
|
||||
heading: {en: 'Experience', vi: 'Kinh nghiệm'},
|
||||
tldr: {en: 'TL;DR', vi: 'TL;DR'},
|
||||
tldrText: {
|
||||
en: '15 years of experience, more than 8 companies along the way. Too long to tell.',
|
||||
vi: '15 năm kinh nghiệm, hơn 8 công ty đã đi qua. Quá dài để kể hết.'
|
||||
},
|
||||
},
|
||||
projects: {
|
||||
featured: {en: 'Featured Projects', vi: 'Dự án nổi bật'},
|
||||
all: {en: 'Projects', vi: 'Dự án'},
|
||||
viewAll: {en: 'View All', vi: 'Xem tất cả'},
|
||||
viewDetails: {en: 'View Details', vi: 'Xem chi tiết'},
|
||||
categories: {
|
||||
'software-engineering': {en: 'Software Engineering', vi: 'Kỹ thuật phần mềm'},
|
||||
logistics: {en: 'Logistics', vi: 'Logistics'},
|
||||
'ai-ml': {en: 'AI / ML', vi: 'AI / ML'},
|
||||
'computer-vision': {en: 'Computer Vision', vi: 'Computer Vision'},
|
||||
architecture: {en: 'Architecture', vi: 'Kiến trúc'},
|
||||
experiment: {en: 'Experiment', vi: 'Thử nghiệm'},
|
||||
},
|
||||
},
|
||||
contact: {
|
||||
heading: {en: 'Contact', vi: 'Liên hệ'},
|
||||
email: {en: 'Email', vi: 'Email'},
|
||||
github: {en: 'GitHub', vi: 'GitHub'},
|
||||
linkedin: {en: 'LinkedIn', vi: 'LinkedIn'},
|
||||
telegram: {en: 'Telegram', vi: 'Telegram'},
|
||||
},
|
||||
projectDetail: {
|
||||
notFound: {en: 'Project Not Found', vi: 'Không tìm thấy dự án'},
|
||||
backToProjects: {en: 'Back to Projects', vi: 'Quay lại dự án'},
|
||||
impact: {en: 'Impact', vi: 'Tác động'},
|
||||
role: {en: 'Role', vi: 'Vai trò'},
|
||||
technologies: {en: 'Technologies', vi: 'Công nghệ'},
|
||||
experiments: {en: 'Engineering Experiments', vi: 'Thí nghiệm kỹ thuật'},
|
||||
},
|
||||
philosophy: {
|
||||
heading: {en: 'Philosophy', vi: 'Triết lý'},
|
||||
quotes: [
|
||||
{
|
||||
title: {en: 'Time is priceless', vi: 'Thời gian là vô giá'},
|
||||
details: {
|
||||
en: '<p>Time is priceless. You can’t buy it, pause it, or rewind it. Once it’s gone, it’s gone for good.</p>' +
|
||||
'<p>We spend so much of our lives chasing things—money, status, validation—but time is the one thing we can never earn back.</p>' +
|
||||
'<p>So be mindful of how you use it. Invest it in what truly matters: the people you love, the goals that inspire you, the moments that feed your soul.</p>',
|
||||
vi: '<p>Thời gian là vô giá. Bạn không thể mua nó bằng tiền, không thể khiến nó dừng lại, cũng chẳng thể quay ngược về quá khứ. Một khi thời gian đã trôi qua, nó sẽ mãi mãi không trở lại.</p>' +
|
||||
'<p>Chúng ta dành quá nhiều thời gian trong cuộc đời để theo đuổi những thứ như tiền bạc, địa vị và sự công nhận từ người khác. Nhưng thời gian là thứ duy nhất mà chúng ta không bao giờ có thể lấy lại.</p>' +
|
||||
'<p>Vì vậy, hãy luôn ý thức về cách bạn sử dụng thời gian của mình. Hãy dành thời gian cho những điều thực sự quan trọng: những người bạn yêu thương, những mục tiêu truyền cảm hứng cho bạn và những khoảnh khắc nuôi dưỡng tâm hồn bạn.</p>'
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
common: {
|
||||
resumeDownload: {en: 'Get Resume', vi: 'Tải CV'},
|
||||
resumeModalTitle: {en: 'Get Resume', vi: 'Tải CV'},
|
||||
resumeModalAria: {en: 'Choose resume language', vi: 'Chọn ngôn ngữ CV'},
|
||||
resumeModalHint: {en: 'Choose a language — the PDF downloads to your device.', vi: 'Chọn ngôn ngữ — PDF sẽ tải về máy của bạn.'},
|
||||
resumeModalClose: {en: 'Close resume options', vi: 'Đóng tùy chọn tải CV'},
|
||||
backToTop: {en: 'Scroll to top', vi: 'Cuộn lên đầu trang'},
|
||||
contactTag: {en: 'Contact', vi: 'Liên hệ'},
|
||||
experienceTag: {en: 'Experience', vi: 'Kinh nghiệm'},
|
||||
},
|
||||
} as const
|
||||
@@ -0,0 +1,144 @@
|
||||
// Cross-document consistency rules (spec-v4 §3.6) — what types cannot express
|
||||
// across two JSON files. Runs at load (dev), in CI (`scripts/validate-content.ts`),
|
||||
// and in the browser before save (edit mode, Phase 3).
|
||||
//
|
||||
// tsc already guarantees each document individually satisfies its declared type
|
||||
// and that `content.vi.json` covers every union id; this module enforces the
|
||||
// relationships BETWEEN documents and reports exact document paths so a content
|
||||
// edit can be fixed in the JSON panel.
|
||||
import type {
|
||||
ContentEn,
|
||||
ContentVi,
|
||||
ExperienceStructure,
|
||||
ProfileStructure,
|
||||
ProjectStructure,
|
||||
SkillGroupStructure,
|
||||
} from './dict-types';
|
||||
|
||||
export type ContentIssue = { path: string; message: string };
|
||||
|
||||
export type ContentStructures = {
|
||||
profile: ProfileStructure;
|
||||
skills: SkillGroupStructure[];
|
||||
experience: ExperienceStructure[];
|
||||
projects: ProjectStructure[];
|
||||
};
|
||||
|
||||
const hasHtml = (value: string) => value.includes('<') || value.includes('>');
|
||||
|
||||
// Walks every string value of a text document, collecting its document path.
|
||||
function findHtmlStrings(value: unknown, docPath: string): string[] {
|
||||
if (typeof value === 'string') return hasHtml(value) ? [docPath] : [];
|
||||
if (Array.isArray(value))
|
||||
return value.flatMap((item, i) => findHtmlStrings(item, `${docPath}[${i}]`));
|
||||
if (value && typeof value === 'object')
|
||||
return Object.entries(value).flatMap(([key, item]) =>
|
||||
findHtmlStrings(item, `${docPath}.${key}`),
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
||||
export function collectContentIssues(
|
||||
structures: ContentStructures,
|
||||
vi: ContentVi,
|
||||
en: ContentEn,
|
||||
): ContentIssue[] {
|
||||
const issues: ContentIssue[] = [];
|
||||
|
||||
// Rule 1: every structure id — and every section id inside a project —
|
||||
// has Vietnamese text. (Section ids collide across projects, so coverage is
|
||||
// enforced per project, not by a global union.)
|
||||
for (const group of structures.skills) {
|
||||
if (!vi.skills[group.id])
|
||||
issues.push({ path: `content.vi.json: skills.${group.id}`, message: 'missing Vietnamese text' });
|
||||
}
|
||||
for (const entry of structures.experience) {
|
||||
if (!vi.experience[entry.id])
|
||||
issues.push({ path: `content.vi.json: experience.${entry.id}`, message: 'missing Vietnamese text' });
|
||||
}
|
||||
for (const project of structures.projects) {
|
||||
const text = vi.projects[project.id];
|
||||
if (!text) {
|
||||
issues.push({ path: `content.vi.json: projects.${project.id}`, message: 'missing Vietnamese text' });
|
||||
continue;
|
||||
}
|
||||
for (const section of project.sections) {
|
||||
if (!text.sections[section.id])
|
||||
issues.push({
|
||||
path: `content.vi.json: projects.${project.id}.sections.${section.id}`,
|
||||
message: 'missing Vietnamese text for section',
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const point of structures.profile.philosophy) {
|
||||
if (!vi.profile.philosophy[point.id])
|
||||
issues.push({
|
||||
path: `content.vi.json: profile.philosophy.${point.id}`,
|
||||
message: 'missing Vietnamese text',
|
||||
});
|
||||
}
|
||||
|
||||
// Rules 2–3: no orphan text keys — every key in either language must
|
||||
// correspond to an id present in structure (partial en coverage is allowed).
|
||||
const skillIds = new Set(structures.skills.map((g) => g.id));
|
||||
const experienceIds = new Set(structures.experience.map((e) => e.id));
|
||||
const projectIds = new Set(structures.projects.map((p) => p.id));
|
||||
const sectionIds = new Map(
|
||||
structures.projects.map((p) => [p.id, new Set(p.sections.map((s) => s.id))]),
|
||||
);
|
||||
const philosophyIds = new Set(structures.profile.philosophy.map((p) => p.id));
|
||||
|
||||
const checkTextDoc = (doc: Partial<ContentVi> | ContentEn, lang: 'vi' | 'en') => {
|
||||
const file = `content.${lang}.json`;
|
||||
for (const id of Object.keys(doc.skills ?? {})) {
|
||||
if (!skillIds.has(id as never))
|
||||
issues.push({ path: `${file}: skills.${id}`, message: 'orphan text key — no such skill group in structure' });
|
||||
}
|
||||
for (const id of Object.keys(doc.experience ?? {})) {
|
||||
if (!experienceIds.has(id as never))
|
||||
issues.push({ path: `${file}: experience.${id}`, message: 'orphan text key — no such experience in structure' });
|
||||
}
|
||||
for (const [id, text] of Object.entries(doc.projects ?? {})) {
|
||||
if (!projectIds.has(id as never)) {
|
||||
issues.push({ path: `${file}: projects.${id}`, message: 'orphan text key — no such project in structure' });
|
||||
continue;
|
||||
}
|
||||
const known = sectionIds.get(id as never)!;
|
||||
for (const sectionId of Object.keys(text.sections ?? {})) {
|
||||
if (!known.has(sectionId))
|
||||
issues.push({
|
||||
path: `${file}: projects.${id}.sections.${sectionId}`,
|
||||
message: "orphan section text key — not in the project's structure",
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const id of Object.keys(doc.profile?.philosophy ?? {})) {
|
||||
if (!philosophyIds.has(id as never))
|
||||
issues.push({ path: `${file}: profile.philosophy.${id}`, message: 'orphan text key — no such philosophy point' });
|
||||
}
|
||||
};
|
||||
checkTextDoc(vi, 'vi');
|
||||
checkTextDoc(en, 'en');
|
||||
|
||||
// Rule 5: text values are plain text — no HTML markup in any content
|
||||
// document (after D9 nothing needs markup; §3.2 keeps rendering separate).
|
||||
for (const [lang, doc] of [['vi', vi], ['en', en]] as const) {
|
||||
for (const path of findHtmlStrings(doc, `content.${lang}.json`)) {
|
||||
issues.push({ path, message: 'text value contains HTML markup' });
|
||||
}
|
||||
}
|
||||
|
||||
return issues;
|
||||
}
|
||||
|
||||
export function validateContent(
|
||||
structures: ContentStructures,
|
||||
vi: ContentVi,
|
||||
en: ContentEn,
|
||||
): void {
|
||||
const issues = collectContentIssues(structures, vi, en);
|
||||
if (issues.length > 0) {
|
||||
const detail = issues.map((i) => ` ${i.path}: ${i.message}`).join('\n');
|
||||
throw new Error(`content validation failed (${issues.length} issue(s)):\n${detail}`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user