fix(import): do not double-escape backslashes in translation JSON - #36
Merged
Conversation
Cover plain units, XML parse, PGS MF1/MF2, and export→import round-trip so JSON.parse keeps a single backslash. Refs #34 Co-authored-by: Cursor <cursoragent@cursor.com>
parseMessage rejects \t/\n as bad MF2 escapes and dropped those segment bodies. Embed XLIFF text as-is and let JSON.stringify be the only JSON encoding step. Refs #34 Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the import spec aligned with treating XLIFF text as already decoded before toJSON. Refs #34 Co-authored-by: Cursor <cursoragent@cursor.com>
jsahleen
marked this pull request as ready for review
August 16, 2026 02:08
|
🎉 This PR is included in version 0.5.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
\n,\t,\\,\{, and\}throughJSON.parseoftoJSON()—JSON.stringifyis the only JSON encoding step.parseMessageon segment bodies (it treated\t/\nasbad-escapeand dropped the text). Raw bodies are spliced into quoted patterns instead, so backslashes are not doubled.\{→'{'); other backslash sequences are preserved.Closes #34.
Test plan
JSON.parse(toJSON())matches XLIFF target\{,\t,\n,\\) survives import\\{in parsed JSONnpm test,npx tsc --noEmit,npm run build,npm run coverageMade with Cursor