[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #124
2 changed files with 15 additions and 1 deletions
2
time.go
2
time.go
|
|
@ -43,7 +43,7 @@ func FormatAgo(count int, unit string) string {
|
|||
svc := Default()
|
||||
unit = normalizeAgoUnit(unit)
|
||||
if svc == nil {
|
||||
return core.Sprintf("%d %ss ago", count, unit)
|
||||
return core.Sprintf("%d %s ago", count, Pluralize(unit, count))
|
||||
}
|
||||
key := "time.ago." + unit
|
||||
result := svc.T(key, map[string]any{"Count": count})
|
||||
|
|
|
|||
14
time_test.go
14
time_test.go
|
|
@ -192,6 +192,20 @@ func TestFormatAgo_Good_SingularUnit(t *testing.T) {
|
|||
assert.Equal(t, "1 fortnight ago", got)
|
||||
}
|
||||
|
||||
func TestFormatAgo_Good_NoDefaultService(t *testing.T) {
|
||||
prev := Default()
|
||||
SetDefault(nil)
|
||||
t.Cleanup(func() {
|
||||
SetDefault(prev)
|
||||
})
|
||||
|
||||
got := FormatAgo(1, "second")
|
||||
assert.Equal(t, "1 second ago", got)
|
||||
|
||||
got = FormatAgo(5, "second")
|
||||
assert.Equal(t, "5 seconds ago", got)
|
||||
}
|
||||
|
||||
func TestFormatAgo_Good_FrenchRelativeTime(t *testing.T) {
|
||||
prev := Default()
|
||||
svc, err := New()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue