-
Notifications
You must be signed in to change notification settings - Fork 662
Added the context snapshot tooling and marker support #1329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Added the context snapshot tooling and marker support #1329
Conversation
Introduces a new 'review' block in i18n.json and CLI commands for capturing context manifests linking localized JSX scopes to DOM markers. The compiler now supports injecting a stable data attribute (default 'data-lingo-id') for each scope, with configurable attribute name and manifest output. Updates include schema, config, tests, and core compiler logic to support context marker injection and manifest generation for improved translator review workflows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces context snapshot tooling to help translators review localized strings with visual context. It adds a new review configuration block in i18n.json (v1.11), enables the compiler to inject stable DOM data attributes (data-lingo-id) on localized JSX scopes, and provides a CLI command to generate context manifests that link compiler scopes to DOM markers.
Key changes:
- New v1.11 config schema with
reviewblock for capturing routes and marker settings - Compiler injects configurable data attributes on JSX elements when
exposeContextAttributeis enabled - New
lingo.dev review captureCLI command generates manifest files from compiled metadata
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/config.ts | Adds v1.11 config with review schema including routes, compiler paths, and marker attribute settings |
| packages/spec/src/config.spec.ts | Updates tests to verify review config is present in upgraded configs |
| packages/compiler/src/utils/context-marker.ts | New utility for validating and resolving context attribute names with data- prefix requirement |
| packages/compiler/src/lib/lcp/schema.ts | Extends LCP scope schema to include optional marker field with attribute and value |
| packages/compiler/src/lib/lcp/index.ts | Adds setScopeMarker method to store marker metadata for each scope |
| packages/compiler/src/jsx-scopes-export.ts | Computes and stores marker values for each JSX scope during export phase |
| packages/compiler/src/jsx-scopes-export.spec.ts | Tests that marker metadata is correctly saved to LCP |
| packages/compiler/src/jsx-scope-inject.ts | Injects context attribute into transformed JSX when exposeContextAttribute is enabled |
| packages/compiler/src/jsx-scope-inject.spec.ts | Tests context marker injection and existing value preservation |
| packages/compiler/src/_base.ts | Adds exposeContextAttribute and contextAttributeName compiler parameters |
| packages/cli/src/cli/index.ts | Registers new review command in CLI |
| packages/cli/src/cli/cmd/review/index.ts | Defines review command with capture subcommand |
| packages/cli/src/cli/cmd/review/capture.ts | Implements manifest generation from meta.json and dictionary.js |
| packages/cli/README.md | Documents new review capture command and workflow |
| i18n.json | Upgrades config to v1.11 with review block |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * The name of the DOM data attribute that will be injected when | ||
| * `exposeContextAttribute` is enabled. Use a `data-*` attribute to avoid | ||
| * interfering with user props. Values that do not start with `data-` fall |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSDoc comment line has inconsistent indentation. It should start with a space after the asterisk like line 76, but it's missing that leading space.
| * interfering with user props. Values that do not start with `data-` fall | |
| * interfering with user props. Values that do not start with `data-` fall |
packages/cli/README.md
Outdated
| --- | ||
|
|
||
| ### 🔄 Lingo.dev CI/CD | ||
| ### �️ Context Snapshot Manifest |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The emoji appears to be corrupted or not rendering properly. Consider using a properly encoded emoji or a text-based icon.
| ### �️ Context Snapshot Manifest | |
| ### 📸 Context Snapshot Manifest |
packages/cli/README.md
Outdated
|
|
||
| --- | ||
|
|
||
| ### �🔄 Lingo.dev CI/CD |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The emoji appears to be corrupted or not rendering properly. Consider using a properly encoded emoji or a text-based icon.
| ### �🔄 Lingo.dev CI/CD | |
| ### 🔄 Lingo.dev CI/CD |
Replaces placeholder emojis with appropriate ones in the CLI README for improved clarity. Refactors the extraction of 'data-lingo-override-' attributes in jsx-scopes-export.ts to use native Object methods instead of lodash chaining, simplifying the code and removing lodash dependency for this logic.
Introduces a new 'review' block in i18n.json and CLI commands for capturing context manifests linking localized JSX scopes to DOM markers. The compiler now supports injecting a stable data attribute (default 'data-lingo-id') for each scope, with configurable attribute name and manifest output. Updates include schema, config, tests, and core compiler logic to support context marker injection and manifest generation for improved translator review workflows.