[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #23
2 changed files with 38 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ package i18n
|
|||
|
||||
import (
|
||||
"maps"
|
||||
"strings"
|
||||
"text/template"
|
||||
"unicode"
|
||||
|
||||
|
|
@ -561,6 +562,9 @@ func ArticlePhrase(word string) string {
|
|||
if article == "" || word == "" {
|
||||
return ""
|
||||
}
|
||||
if strings.HasSuffix(article, "'") {
|
||||
return article + word
|
||||
}
|
||||
return article + " " + word
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -366,6 +366,40 @@ func TestArticlePhrase(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestArticlePhraseFrenchLocale(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)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
word string
|
||||
want string
|
||||
}{
|
||||
{"branche", "la branche"},
|
||||
{"enfant", "l'enfant"},
|
||||
{"fichier", "le fichier"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.word, func(t *testing.T) {
|
||||
got := ArticlePhrase(tt.word)
|
||||
if got != tt.want {
|
||||
t.Errorf("ArticlePhrase(%q) = %q, want %q", tt.word, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLabel(t *testing.T) {
|
||||
svc, err := New()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue