Skip to content

fix(import): do not double-escape backslashes in translation JSON - #36

Merged
jsahleen merged 3 commits into
mainfrom
msg-cli-34
Aug 16, 2026
Merged

fix(import): do not double-escape backslashes in translation JSON#36
jsahleen merged 3 commits into
mainfrom
msg-cli-34

Conversation

@jsahleen

Copy link
Copy Markdown
Collaborator

Summary

  • Plain XLIFF targets keep \n, \t, \\, \{, and \} through JSON.parse of toJSON()JSON.stringify is the only JSON encoding step.
  • PGS MF2 import no longer runs parseMessage on segment bodies (it treated \t/\n as bad-escape and dropped the text). Raw bodies are spliced into quoted patterns instead, so backslashes are not doubled.
  • PGS MF1 still ICU-quotes literal braces (\{'{'); other backslash sequences are preserved.

Closes #34.

Test plan

  • Plain unit + real XML parse: JSON.parse(toJSON()) matches XLIFF target
  • PGS MF2 kitchen-sink body (\{, \t, \n, \\) survives import
  • PGS MF1 does not emit \\{ in parsed JSON
  • NONE export→import round-trip
  • Existing PGS round-trips still pass
  • npm test, npx tsc --noEmit, npm run build, npm run coverage

Made with Cursor

jsahleen and others added 3 commits August 15, 2026 20:07
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
jsahleen marked this pull request as ready for review August 16, 2026 02:08
@jsahleen
jsahleen merged commit 073ec52 into main Aug 16, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.5.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not double-escape backslash sequences when importing XLIFF to JSON

1 participant