[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #84
2 changed files with 38 additions and 0 deletions
16
handler.go
16
handler.go
|
|
@ -134,6 +134,10 @@ func DefaultHandlers() []KeyHandler {
|
|||
}
|
||||
|
||||
func countWordForm(lang, noun string, count int) string {
|
||||
if hasGrammarCountForms(lang, noun) {
|
||||
return Pluralize(noun, count)
|
||||
}
|
||||
|
||||
display := renderWord(lang, noun)
|
||||
if display == "" {
|
||||
return Pluralize(noun, count)
|
||||
|
|
@ -150,6 +154,18 @@ func countWordForm(lang, noun string, count int) string {
|
|||
return Pluralize(display, count)
|
||||
}
|
||||
|
||||
func hasGrammarCountForms(lang, noun string) bool {
|
||||
data := GetGrammarData(lang)
|
||||
if data == nil || len(data.Nouns) == 0 {
|
||||
return false
|
||||
}
|
||||
forms, ok := data.Nouns[core.Lower(noun)]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return forms.One != "" || forms.Other != ""
|
||||
}
|
||||
|
||||
func isPluralisableWordDisplay(s string) bool {
|
||||
hasLetter := false
|
||||
for _, r := range s {
|
||||
|
|
|
|||
|
|
@ -287,6 +287,28 @@ func TestCountHandler_PreservesPhraseDisplay(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCountHandler_PluralisesLocaleNounPhrases(t *testing.T) {
|
||||
prev := Default()
|
||||
svc, err := New()
|
||||
if err != nil {
|
||||
t.Fatalf("New() failed: %v", err)
|
||||
}
|
||||
SetDefault(svc)
|
||||
t.Cleanup(func() {
|
||||
SetDefault(prev)
|
||||
})
|
||||
|
||||
if err := SetLanguage("fr"); err != nil {
|
||||
t.Fatalf("SetLanguage(fr) failed: %v", err)
|
||||
}
|
||||
|
||||
h := CountHandler{}
|
||||
got := h.Handle("i18n.count.mise à jour", []any{2}, nil)
|
||||
if got != "2 mises à jour" {
|
||||
t.Fatalf("CountHandler.Handle(mise à jour, 2) = %q, want %q", got, "2 mises à jour")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunHandlerChain(t *testing.T) {
|
||||
handlers := DefaultHandlers()
|
||||
fallback := func() string { return "missed" }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue