Skip to content

feat(resource): format-aware pseudo-localization for MF1/MF2/NONE - #60

Merged
jsahleen merged 7 commits into
mainfrom
msg-59
Aug 11, 2026
Merged

feat(resource): format-aware pseudo-localization for MF1/MF2/NONE#60
jsahleen merged 7 commits into
mainfrom
msg-59

Conversation

@jsahleen

@jsahleen jsahleen commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Make getTranslation(pseudoLocale) honor each message's resolved format (MF1 | MF2 | NONE) instead of always parsing as MF2.
  • Add src/lib/pseudo-localize.ts helpers: MF2 AST walk, MF1 via @messageformat/parser content-offset rebuild (skipping function arg styles), and whole-string NONE.
  • Preserve per-message attributes (including format overrides) on the pseudo-localized resource.
  • Document format-aware behavior in README / GETTING_STARTED / JSDoc.

Closes #59

Test plan

  • npm test — 110 tests green
  • MF1 plural/select/function-style cases; mixed-format resource; NONE
  • Integration: pseudoLocale + format() still works for MF1/MF2/NONE
  • npx tsc --noEmit and npm run build clean
  • npm run coverage — 100% statements/lines (> 90%)
  • CI green on the PR

jsahleen and others added 7 commits August 10, 2026 20:37
Extract MF2/NONE helpers to src/lib; stub MF1 for TDD. Add
@messageformat/parser as a direct dependency. Refs #59.

Co-authored-by: Cursor <cursoragent@cursor.com>
Dispatch pseudo-locale values via pseudoLocalize using each
message's resolved format; cover MF1/NONE/mixed cases. Refs #59.

Co-authored-by: Cursor <cursoragent@cursor.com>
Walk @messageformat/parser AST content tokens (skipping function
arg styles) and replace spans in the original source so ICU
structure is preserved. Refs #59.

Co-authored-by: Cursor <cursoragent@cursor.com>
Propagate inFunctionParam through nested selects, rebuild via
ascending cursor, and tighten format-dispatch assertions. Refs #59.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cover mixed-format pseudoLocale formatting end-to-end, MF1
no-content spans, and getTranslation() cloning. Refs #59.

Co-authored-by: Cursor <cursoragent@cursor.com>
Update README, GETTING_STARTED, and getTranslation JSDoc for
MF1/MF2/NONE pseudo-locale behavior. Refs #59.

Co-authored-by: Cursor <cursoragent@cursor.com>
Build pseudo messages with map; make the MF1 AST walk exhaustively
handle argument/octothorpe tokens. Refs #59.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jsahleen
jsahleen marked this pull request as ready for review August 11, 2026 02:46
@jsahleen
jsahleen merged commit c68b310 into main Aug 11, 2026
1 check passed
@jsahleen
jsahleen deleted the msg-59 branch August 11, 2026 02:51
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.11.0 🎉

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.

Support MF1 and NONE in pseudo-localization

1 participant