[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #77
3 changed files with 25 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package i18n
|
||||
|
||||
import "fmt"
|
||||
|
||||
// TranslationContext provides disambiguation for translations.
|
||||
//
|
||||
// T("direction.right", C("navigation")) // "rechts" (German)
|
||||
|
|
@ -82,6 +84,13 @@ func (c *TranslationContext) ContextString() string {
|
|||
return c.Context
|
||||
}
|
||||
|
||||
func (c *TranslationContext) String() string {
|
||||
if c == nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprint(c.Context)
|
||||
}
|
||||
|
||||
func (c *TranslationContext) GenderString() string {
|
||||
if c == nil {
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ func TestC_Good(t *testing.T) {
|
|||
require.NotNil(t, ctx)
|
||||
assert.Equal(t, "navigation", ctx.Context)
|
||||
assert.Equal(t, "navigation", ctx.ContextString())
|
||||
assert.Equal(t, "navigation", ctx.String())
|
||||
}
|
||||
|
||||
func TestC_Good_EmptyContext(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,11 @@ func TestProgressHandler(t *testing.T) {
|
|||
if got != "Building config.yaml..." {
|
||||
t.Errorf("ProgressHandler.Handle(build, Subject) = %q, want %q", got, "Building config.yaml...")
|
||||
}
|
||||
|
||||
got = h.Handle("i18n.progress.build", []any{C("project")}, nil)
|
||||
if got != "Building project..." {
|
||||
t.Errorf("ProgressHandler.Handle(build, TranslationContext) = %q, want %q", got, "Building project...")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCountHandler(t *testing.T) {
|
||||
|
|
@ -123,6 +128,11 @@ func TestDoneHandler(t *testing.T) {
|
|||
t.Errorf("DoneHandler.Handle(delete, Subject) = %q, want %q", got, "Config.yaml deleted")
|
||||
}
|
||||
|
||||
got = h.Handle("i18n.done.delete", []any{C("config.yaml")}, nil)
|
||||
if got != "Config.yaml deleted" {
|
||||
t.Errorf("DoneHandler.Handle(delete, TranslationContext) = %q, want %q", got, "Config.yaml deleted")
|
||||
}
|
||||
|
||||
// Without subject — just past tense
|
||||
got = h.Handle("i18n.done.delete", nil, nil)
|
||||
if got != "Deleted" {
|
||||
|
|
@ -147,6 +157,11 @@ func TestFailHandler(t *testing.T) {
|
|||
t.Errorf("FailHandler.Handle(push, Subject) = %q, want %q", got, "Failed to push commits")
|
||||
}
|
||||
|
||||
got = h.Handle("i18n.fail.push", []any{C("commits")}, nil)
|
||||
if got != "Failed to push commits" {
|
||||
t.Errorf("FailHandler.Handle(push, TranslationContext) = %q, want %q", got, "Failed to push commits")
|
||||
}
|
||||
|
||||
got = h.Handle("i18n.fail.push", nil, nil)
|
||||
if got != "Failed to push" {
|
||||
t.Errorf("FailHandler.Handle(push) = %q, want %q", got, "Failed to push")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue