feat: add support for locked patterns in mdx loader#700
Merged
maxprilutskiy merged 8 commits intomainfrom May 2, 2025
Merged
Conversation
Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…ontain Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com>
Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com>
Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com>
Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com>
Comment on lines
+59
to
+78
| async pull(locale, input, initCtx, originalLocale) { | ||
| const patterns = defaultPatterns || []; | ||
|
|
||
| const { content, lockedPlaceholders } = extractLockedPatterns(input || "", patterns); | ||
|
|
||
| return { | ||
| content, | ||
| lockedPlaceholders, | ||
| }; | ||
| }, | ||
|
|
||
| async push(locale, data) { | ||
| let result = data.content; | ||
| for (const [placeholder, original] of Object.entries(data.lockedPlaceholders)) { | ||
| result = result.replaceAll(placeholder, original); | ||
| } | ||
|
|
||
| return result; | ||
| }, | ||
| }); |
Contributor
There was a problem hiding this comment.
- should return string, not obkect
- in push, use pullInput +extractLockedPatterns again to recreate the lockedPlaceholders map
…Input Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com>
Comment on lines
+62
to
+80
| async push(locale, data) { | ||
| const patterns = defaultPatterns || []; | ||
|
|
||
| const pullInput = (global as any).__pullInput || null; | ||
|
|
||
| if (!pullInput) { | ||
| return data; | ||
| } | ||
|
|
||
| const { lockedPlaceholders } = extractLockedPatterns(pullInput, patterns); | ||
|
|
||
| let result = data; | ||
| for (const [placeholder, original] of Object.entries(lockedPlaceholders)) { | ||
| result = result.replaceAll(placeholder, original); | ||
| } | ||
|
|
||
| return result; | ||
| }, | ||
| }); |
Contributor
There was a problem hiding this comment.
refer to the definition of createLoader to understand how to use pull input
…ameter Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com>
mainstar123
pushed a commit
to mainstar123/lingo.dev
that referenced
this pull request
Jul 7, 2025
* feat: add support for locked patterns in mdx loader Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * test: update locked patterns tests to use toBe instead of toMatch/toContain Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * fix(mdx): fix locked patterns tests and improve regex patterns Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * fix: make locked patterns configurable via i18n.json Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * refactor: remove default patterns fallback in locked patterns loader Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * refactor: update locked patterns loader to return string and use pullInput Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * refactor: update locked patterns loader to properly use pullInput parameter Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Max Prilutskiy <maks.prilutskiy@gmail.com> Co-authored-by: Max Prilutskiy <5614659+maxprilutskiy@users.noreply.github.com>
17prateek12
pushed a commit
to 17prateek12/lingo.dev
that referenced
this pull request
Jan 23, 2026
* feat: add support for locked patterns in mdx loader Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * test: update locked patterns tests to use toBe instead of toMatch/toContain Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * fix(mdx): fix locked patterns tests and improve regex patterns Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * fix: make locked patterns configurable via i18n.json Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * refactor: remove default patterns fallback in locked patterns loader Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * refactor: update locked patterns loader to return string and use pullInput Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * refactor: update locked patterns loader to properly use pullInput parameter Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Max Prilutskiy <maks.prilutskiy@gmail.com> Co-authored-by: Max Prilutskiy <5614659+maxprilutskiy@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for locked patterns in MDX loader
This PR adds support for preserving specific patterns in MDX files during translation, focusing on the syntax used in documentation like the Solana examples.
Implementation Details
!paramssyntax!! parameter_nameheadings!type stringdeclarations!requiredflags!valueslistsConfiguration
The implementation adds a new field to the bucket configuration in i18n.json:
Testing
Link to Devin run: https://app.devin.ai/sessions/e0df584394174a33ae57acca13dddba7
Requestor: Max Prilutskiy (max@lingo.dev)