feat: string message keys and named template parameters#4
Merged
cmelgarejo merged 5 commits intomainfrom Feb 26, 2026
Merged
Conversation
- Message lookup: numeric codes → string keys (e.g. greeting.hello, error.not_found)
- YAML set: map[string]RawMessage, optional per-entry code; removed Group
- Templates: positional params → named ({{name}}, {{plural:count|...}}, {{num:amount}}, {{date:when}})
- API: GetMessageWithCtx(ctx, msgKey string, params Params); Params = map[string]interface{}
- LoadMessages: RawMessage.Key required with sys. prefix; RuntimeKeyPrefix constant
- Observer/stats: OnMessageMissing(lang, msgKey string), OnTemplateIssue(lang, msgKey string, issue string)
- Tests, mocks, fuzz, bench, examples, README, CONTEXT7 docs updated
Implements docs/CONVERSION_PLAN.md
Made-with: Cursor
- Code is optional and string: OptionalCode (YAML int/string), Message.Code and ErrorCode() string - RawMessage.Code: any value, not unique; helpers CodeInt(), CodeString() - Message.Key and ErrorKey() for API identifier when code is empty - Constants CodeMissingMessage/Language as strings (msgcat.missing_*) - New code.go: OptionalCode, UnmarshalYAML, CodeInt, CodeString - Docs: 'Message and error codes' section (README, CONTEXT7, CONTEXT7_RETRIEVAL) - Runnable examples: basic, load_messages, reload, strict, stats; http/metrics resources Made-with: Cursor
…eased, duplicate-code test, YAML code type Made-with: Cursor
…/merge - CLDR plural forms: RawMessage.ShortForms/LongForms/PluralParam, internal/plural - MessageDef type; CLI extract finds MessageDef literals and merges into source YAML - Optional group (OptionalGroup) on Messages; CLI preserves in extract/merge - cmd/msgcat: extract (keys + sync with MessageDef), merge (translate.<lang>.yaml) - Examples: cldr_plural, msgdef. Docs: CLI_WORKFLOW_PLAN, CLDR_AND_GO_MESSAGES_PLAN - README, CONTEXT7, CONTEXT7_RETRIEVAL, CHANGELOG updated Made-with: Cursor
…, CI, tests - LoadMessages: preserve ShortForms, LongForms, PluralParam on runtime messages - Merge: treat target as translated when it has short_forms/long_forms (not only short/long) - CI: Go 1.26, build ./cmd/... - MIGRATION §10: new optional features (no migration required) - Tests: LoadMessages_preservesShortFormsLongFormsPluralParam, Merge_preservesTargetWhenOnlyForms - CHANGELOG: Fixed, Changed Made-with: Cursor
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.
Implements the full conversion from numeric message codes and positional template parameters to string message keys and named parameters as specified in
docs/CONVERSION_PLAN.md.Summary
int→string(e.g.greeting.hello,error.not_found)setismap[string]RawMessage; optionalcodeper entry;groupremoved{{0}}→{{name}};{{plural:count|item|items}},{{num:amount}},{{date:when}}GetMessageWithCtx(ctx, msgKey string, params Params);Params = map[string]interface{}RawMessage.Keyrequired withsys.prefixOnMessageMissing(lang, msgKey string),OnTemplateIssue(lang, msgKey string, issue string)All tests pass. No backward compatibility (lib not used elsewhere yet).
Made with Cursor