fix(newsletter): preserve source-language image labels

This commit is contained in:
tiennm99 committed 2026-07-11 18:36:03 +07:00
1 parent ac151ba310
commit 6f102c4a63
4 files changed
+14 -5

No files matched your search

+4 -2
View File
@@ -11,6 +11,8 @@ Shared scripts: `scripts/newsletter/`. Shared procedure: `../mt-add-url/referenc
**Label priority:** figure caption → source post title → your typed input.
**Label language:** Preserve the selected label's original source-language wording, capitalization, and punctuation. Do not translate or localize it unless the user explicitly asks. Preserve user-typed labels exactly as entered.
## Input
A clean image URL (passed by `mt-add-url`, or given directly).
@@ -48,7 +50,7 @@ ByteByteGo doesn't attach captions to images (verified: empty `alt`, no `<figcap
- "Image is from **[postTitle]** (`postUrl`). Which title matches it?"
- Offer the candidates. If there are more than 4, show them as a numbered list in text and ask the user to pick a number (AskUserQuestion allows max 4 options).
- Always include a "Type my own" escape.
3. Label = the user's pick (or the typed value). Localize to Vietnamese where natural; keep proper nouns.
3. Label = the user's pick (or the typed value). Preserve its original language, wording, capitalization, and punctuation; do not translate unless the user explicitly asks.
### 2b. Non-Substack image (`isSubstack: false`)
Best-effort only (no reverse-image-search): if you happen to know the page that contains the image, WebFetch it and read the OpenGraph title / nearby caption. Usually there's no containing page from just an image URL → go to step 3.
@@ -81,4 +83,4 @@ Create `### Bonus` / `**Images:**` if missing.
- [ ] Source detected (substack + uuid, or non-substack)
- [ ] Label confirmed (caption if present, else user picked from candidates, else typed)
- [ ] Entry under Bonus → **Images** (section/subsection created if missing)
- [ ] Label localized to Vietnamese where natural (keep proper nouns)
- [ ] Label preserves original source language, wording, capitalization, and punctuation unless the user requested translation
@@ -92,6 +92,11 @@ These rules apply only to text written into `content/post/**/index.md`. Keep use
- Action verbs: use → sử dụng, check → kiểm tra, build → xây dựng, test → kiểm thử
- Any other term: translate if a common Vietnamese equivalent exists
**Preserve original source language:**
- Article headings and image labels must retain the source wording, capitalization, and punctuation.
- Do not translate or localize article headings or image labels unless the user explicitly asks.
- Video titles follow the `mt-add-video` handler's localization rules.
**Content requirements:** audience = junior developers; tone = professional, clear, accessible; verify content is ≥99% Vietnamese before saving.
## 6. Error handling
+1 -1
View File
@@ -10,7 +10,7 @@ Canonical instructions for AI coding tools (Claude Code, OpenCode, Codex) workin
- **User communication**: English by default; use another language only when the user explicitly requests it
- **Timezone**: Asia/Ho_Chi_Minh (UTC+7)
Vietnamese language requirements apply only to content written into Hugo posts, including summaries and localized labels. Keep questions, status updates, reports, and final responses in English unless the user asks for another language.
Vietnamese language requirements apply only to prose written into Hugo posts, including summaries. Preserve article titles and image labels in their original source language, wording, capitalization, and punctuation; translate them only when the user explicitly asks. Keep questions, status updates, reports, and final responses in English unless the user asks for another language.
## Directory Structure
+4 -2
View File
@@ -13,6 +13,8 @@ Shared scripts: `scripts/newsletter/` (run from repo root). Shared procedure: `.
**Label priority:** figure caption → source post title → user-typed input.
**Label language:** Preserve the selected label's original source-language wording, capitalization, and punctuation. Do not translate or localize it unless the user explicitly asks. Preserve user-typed labels exactly as entered.
## Workflow
### 1. Detect source
@@ -40,7 +42,7 @@ node scripts/newsletter/find-substack-post.js --uuid <uuid>
ByteByteGo attaches no captions and image order can't be auto-mapped, so the script returns `candidates` (the newsletter post's topic titles).
1. If `caption` is non-empty → propose it as default.
2. Otherwise present `candidates` to the user: "Image is from **[postTitle]** (`postUrl`). Which title matches it?" Offer the candidates (numbered list if many). Always include a "Type my own" escape.
3. Label = user's pick (or typed). Localize to Vietnamese where natural; keep proper nouns.
3. Label = user's pick (or typed). Preserve its original language, wording, capitalization, and punctuation; do not translate unless the user explicitly asks.
### 2b. Non-Substack image (`isSubstack: false`)
Best-effort only: if you know the containing page, fetch it and read the OpenGraph title / nearby caption. Usually none → go to step 3.
@@ -71,4 +73,4 @@ Create `### Bonus` / `**Images:**` if missing.
- [ ] Source detected (substack + uuid, or non-substack)
- [ ] Label confirmed (caption, else user pick from candidates, else typed)
- [ ] Entry under Bonus → **Images** (section/subsection created if missing)
- [ ] Label localized to Vietnamese where natural (keep proper nouns)
- [ ] Label preserves original source language, wording, capitalization, and punctuation unless the user requested translation