Skip to content

feat(translation): glossary-based tag translation + Lexical image caption translation - #2816

Merged
Innei merged 1 commit into
masterfrom
feat/tag-glossary-caption-translation
Sep 2, 2026
Merged

feat(translation): glossary-based tag translation + Lexical image caption translation#2816
Innei merged 1 commit into
masterfrom
feat/tag-glossary-caption-translation

Conversation

@Innei

@Innei Innei commented Sep 2, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #2815.

  • Tags via glossary: new post.tag dict keyPath in translation entries. Auto-collected on POST_CREATE/UPDATE/REPUBLISH (gated by enableAutoGenerateTranslation), full backfill through the existing admin "generate entries" action. Per-article AI translation no longer translates tags; data.tags always carries the source names.
  • Delivery: new meta.glossary.tags: [{ source, translated }] on post list/detail, category tag list, category detail (tagsSum + children) and the ?tag=true route. Pairs instead of a keyed map so free-text tag names survive the response case transform. api-client base meta type updated.
  • Image captions: image (caption, altText) and gallery (images[].alt) join COMPLEX_NODE_EXTRACTORS in the Lexical translation parser, and block fingerprints include them so caption edits mark the block stale.

Design: docs/superpowers/specs/2026-09-02-tag-glossary-and-image-caption-translation-design.md.

Not wired: /aggregate titled items and /search (no consumer renders tags there). ai_translations.tags column is kept, now holding source tags; can be dropped in a later contract migration.

Test plan

  • lexical-translation-parser.spec: image/gallery segments, round-trip restore
  • helper.lexical.service.spec: caption/alt change fingerprint
  • translation-entry.service.spec, new ai-translation-event-handler.service.spec, helper.translation.service.spec (buildTagGlossary, tags untouched by article translation)
  • tsc --noEmit, eslint on changed files
  • Frontend PR (Yohaku) reads meta.glossary.tags

https://claude.ai/code/session_01EMxdDyw65qUBDpRERXqp3y

…aption translation

Tags now translate through translation entries (post.tag dict keyPath) instead of per-article AI translation; the source tag stays in data.tags and translated names ride in meta.glossary.tags. Image/gallery captions and alt text join the Lexical translation walk and block fingerprints.

Closes #2815

Claude-Session: https://claude.ai/code/session_01EMxdDyw65qUBDpRERXqp3y
@safedep

safedep Bot commented Sep 2, 2026

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

View complete scan results →

This report is generated by SafeDep GitHub App

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T09:47:20.815798Z 649301e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Innei
Innei merged commit e7104fd into master Sep 2, 2026
13 of 14 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 649301e181

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (initial.tags?.length) {
fullTranslations[META_TAGS_KEY] = encodeTags(initial.tags)
}
for (const paragraph of paragraphs) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove tags from the Markdown writer prompt

When translating a Markdown post with tags, deleting the reviewer unit here does not stop per-article tag translation: the writer call still passes tags: content.tags to AI_PROMPTS.translationStream, whose prompt includes a TAGS block and requires translated tag output. Markdown translations therefore still spend tokens translating tags and persist those per-article results—including through the raw translation endpoints—even though delivery has moved tags to the glossary; omit tags from the writer input/output contract as well.

Useful? React with 👍 / 👎.

Comment on lines +269 to +270
lookupKey: TranslationEntryService.hashSourceText(tag),
sourceText: tag,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve distinct source tags in glossary lookups

When posts contain distinct tags that differ only by case or surrounding whitespace, such as React and react, hashSourceText gives them the same lookup key here. The database uniqueness constraint and the serving-time hashToText map then collapse the two entries, so a tag-list response containing both exact, case-sensitive route names can emit a glossary pair for only one of them. Use an exact-source lookup key for post.tag, or retain every source alias when resolving a normalized key.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

图片 caption 不会被翻译

1 participant