[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #38
2 changed files with 29 additions and 0 deletions
|
|
@ -267,6 +267,30 @@ func TestServiceTranslationContextExtrasInTemplates(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestServiceSubjectCountPlurals(t *testing.T) {
|
||||
svc, err := New()
|
||||
if err != nil {
|
||||
t.Fatalf("New() failed: %v", err)
|
||||
}
|
||||
|
||||
if err := svc.loadJSON("en", []byte(`{
|
||||
"item_count": {
|
||||
"one": "{{.Count}} item",
|
||||
"other": "{{.Count}} items"
|
||||
}
|
||||
}`)); err != nil {
|
||||
t.Fatalf("loadJSON() failed: %v", err)
|
||||
}
|
||||
|
||||
if got := svc.T("item_count", S("item", "config.yaml").Count(1)); got != "1 item" {
|
||||
t.Errorf("T(item_count, Count(1)) = %q, want %q", got, "1 item")
|
||||
}
|
||||
|
||||
if got := svc.T("item_count", S("item", "config.yaml").Count(3)); got != "3 items" {
|
||||
t.Errorf("T(item_count, Count(3)) = %q, want %q", got, "3 items")
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceTemplatesSupportGrammarFuncs(t *testing.T) {
|
||||
svc, err := New()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ func getCount(data any) int {
|
|||
return 0
|
||||
}
|
||||
switch d := data.(type) {
|
||||
case *Subject:
|
||||
if d == nil {
|
||||
return 0
|
||||
}
|
||||
return d.CountInt()
|
||||
case map[string]any:
|
||||
if c, ok := d["Count"]; ok {
|
||||
return toInt(c)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue