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

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

View file

@ -17,7 +17,10 @@ func TimeAgo(t time.Time) string {
}
switch {
case duration < 5*time.Second:
return T("time.just_now")
if text := T("time.just_now"); text != "time.just_now" {
return text
}
return "just now"
case duration < time.Minute:
return FormatAgo(int(duration/time.Second), "second")
case duration < time.Hour:

View file

@ -2,6 +2,7 @@ package i18n
import (
"testing"
"testing/fstest"
"time"
"github.com/stretchr/testify/assert"
@ -93,6 +94,24 @@ func TestTimeAgo_Good_SingleUnits(t *testing.T) {
assert.Contains(t, got, "1 week ago")
}
func TestTimeAgo_Good_MissingJustNowKeyFallback(t *testing.T) {
svc, err := NewWithFS(fstest.MapFS{
"xx.json": &fstest.MapFile{
Data: []byte(`{}`),
},
}, ".")
require.NoError(t, err)
prev := Default()
SetDefault(svc)
t.Cleanup(func() {
SetDefault(prev)
})
got := TimeAgo(time.Now().Add(-4 * time.Second))
assert.Equal(t, "just now", got)
}
// --- FormatAgo ---
func TestFormatAgo_Good(t *testing.T) {