Conversation
Introduce the `MsgFormat` union ('MF1' | 'MF2' | 'NONE') and a
`format` attribute, plus a project-level `format` (default MF2) that
resources will inherit. Align messageformat to 4.0.0 stable and add
@messageformat/icu-messageformat-1 for MF1 support.
Refs #33
Co-authored-by: Cursor <cursoragent@cursor.com>
Cover project/resource/message format inheritance, MF1/MF2/NONE formatting behavior, and format-aware serialization. Also update the MF2 formatToParts snapshot for messageformat 4.0.0 (the `number` part no longer includes a `source` field). Refs #33 Co-authored-by: Cursor <cursoragent@cursor.com>
format/formatToParts now resolve the message's format (default MF2): MF1 compiles via mf1ToMessage, MF2 uses MessageFormat, and NONE returns the raw string / a single text part. Fix the MF1 formatToParts test to match the real nested number part shape. Refs #33 Co-authored-by: Cursor <cursoragent@cursor.com>
Resources inherit the project's format at creation; hasMatchingAttributes accounts for format so inherited values collapse on serialization. getData omits format on a resource when it equals the project's and on a message when it equals its resource's. Refs #33 Co-authored-by: Cursor <cursoragent@cursor.com>
translate() now carries the source resource's and each source message's format into the translated copy unless the translation explicitly sets its own, so MF1/NONE settings survive translation. Refs #33 Co-authored-by: Cursor <cursoragent@cursor.com>
End-to-end coverage of MF1/MF2/NONE formatting, format-aware serialization with round-trip, and translate preservation across a single project, plus the default-fallback branches. Refs #33 Co-authored-by: Cursor <cursoragent@cursor.com>
Add a CI workflow triggered on pull_request and pushes to main so the Definition-of-done checks gate every PR (there was previously only a release-triggered publish workflow). Refs #33 Co-authored-by: Cursor <cursoragent@cursor.com>
Update README for the inheritable format attribute (MF1/MF2/NONE), add a GETTING_STARTED guide, export the shared types (MsgFormat, MsgAttributes, ...) from the package root, and add a typedoc `docs` script. Generated docs/ output is gitignored like dist/coverage. Refs #33 Co-authored-by: Cursor <cursoragent@cursor.com>
jsahleen
marked this pull request as ready for review
July 19, 2026 20:51
|
🎉 This PR is included in version 0.8.0 🎉 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
Closes #33.
Adds support for formatting MF1, MF2, and NONE strings via a new, inheritable
formatattribute.MsgFormatunion type ('MF1' | 'MF2' | 'NONE', not an enum) and aformatattribute; defaults toMF2for backwards compatibility.format; resources inherit from the project and messages inherit from their resource unless they specify their own.MsgMessage.format/formatToPartsbranch on the resolved format:MF2→MessageFormat,MF1→mf1ToMessagefrom@messageformat/icu-messageformat-1,NONE→ the raw string (a single text part forformatToParts).formaton a resource when it equals the project's, and on a message when it equals its resource's.translate()preserves the source resource's and each message'sformatunless the translation overrides it.messageformatto4.0.0(stable) somf1ToMessage'sMessageFormatshares a single instance with ours; adds@messageformat/icu-messageformat-1.MsgFormat,MsgAttributes, ...) from the package root.Public API
Additive only: a new optional
formatattribute, aMsgProject.formataccessor, and newly exported types. TheMF2default keeps existing behavior unchanged.Test plan
npm test— 97 tests green (MF1/MF2/NONE formatting, inheritance, serialization, translation, plus integration/e2e)npx tsc --noEmit— no type errorsnpm run build— clean tsup buildnpm run coverage— 100% statements/branches/functions/lines.github/workflows/ci.yml)Docs
README.mdupdated (Message Formats section + API reference).GETTING_STARTED.md.npm run docs(typedoc) generates browsable API docs into the gitignoreddocs/.Notes
formatToPartssnapshot was updated formessageformat@4.0.0(thenumberpart no longer includes asourcefield).docs/handling and documenting the CI workflow) will land in a separate meta-PR.