[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #113

Merged
Virgil merged 1 commit from agent/read---spec-code-core-go-i18n-rfc-md-ful into dev 2026-04-02 04:30:20 +00:00
2 changed files with 14 additions and 8 deletions

10
i18n.go
View file

@ -93,14 +93,18 @@ func CurrentDebug() bool {
return false
}
// N formats a number using the i18n.numeric.* namespace.
// N formats a value using the i18n.numeric.* namespace.
//
// N("number", 1234567) // "1,234,567"
// N("percent", 0.85) // "85%"
// N("bytes", 1536000) // "1.46 MB"
// N("ordinal", 1) // "1st"
func N(format string, value any) string {
return T("i18n.numeric."+format, value)
//
// Multi-argument formats such as "ago" also pass through unchanged:
//
// N("ago", 5, "minutes") // "5 minutes ago"
func N(format string, value any, args ...any) string {
return T("i18n.numeric."+format, append([]any{value}, args...)...)
}
// Prompt translates a prompt key from the prompt namespace.

View file

@ -142,16 +142,18 @@ func TestN_Good(t *testing.T) {
name string
format string
value any
args []any
want string
}{
{"number", "number", int64(1234567), "1,234,567"},
{"percent", "percent", 0.85, "85%"},
{"bytes", "bytes", int64(1536000), "1.46 MB"},
{"ordinal", "ordinal", 1, "1st"},
{"number", "number", int64(1234567), nil, "1,234,567"},
{"percent", "percent", 0.85, nil, "85%"},
{"bytes", "bytes", int64(1536000), nil, "1.46 MB"},
{"ordinal", "ordinal", 1, nil, "1st"},
{"ago", "ago", 5, []any{"minutes"}, "5 minutes ago"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := N(tt.format, tt.value)
got := N(tt.format, tt.value, tt.args...)
assert.Equal(t, tt.want, got)
})
}