[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #119
2 changed files with 25 additions and 8 deletions
10
service.go
10
service.go
|
|
@ -403,17 +403,11 @@ func (s *Service) resolveWithFallback(messageID string, data any) string {
|
|||
parts := core.Split(messageID, ".")
|
||||
verb := parts[len(parts)-1]
|
||||
commonKey := "common.action." + verb
|
||||
if text := s.tryResolve(s.currentLang, commonKey, data); text != "" {
|
||||
return text
|
||||
}
|
||||
if text := s.tryResolve(s.fallbackLang, commonKey, data); text != "" {
|
||||
if text := s.resolveDirect(commonKey, data); text != "" {
|
||||
return text
|
||||
}
|
||||
commonKey = "common." + verb
|
||||
if text := s.tryResolve(s.currentLang, commonKey, data); text != "" {
|
||||
return text
|
||||
}
|
||||
if text := s.tryResolve(s.fallbackLang, commonKey, data); text != "" {
|
||||
if text := s.resolveDirect(commonKey, data); text != "" {
|
||||
return text
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,6 +296,29 @@ func TestServiceMessageFallbackUsesBaseLanguageTagBeforeConfiguredFallback(t *te
|
|||
}
|
||||
}
|
||||
|
||||
func TestServiceCommonFallbackUsesBaseLanguageTagBeforeConfiguredFallback(t *testing.T) {
|
||||
svc, err := NewWithLoader(messageBaseFallbackLoader{})
|
||||
if err != nil {
|
||||
t.Fatalf("NewWithLoader() failed: %v", err)
|
||||
}
|
||||
|
||||
svc.AddMessages("en", map[string]string{
|
||||
"common.action.status": "Common status",
|
||||
})
|
||||
svc.AddMessages("fr", map[string]string{
|
||||
"common.action.status": "Statut commun",
|
||||
})
|
||||
|
||||
if err := svc.SetLanguage("en-GB"); err != nil {
|
||||
t.Fatalf("SetLanguage(en-GB) failed: %v", err)
|
||||
}
|
||||
svc.SetFallback("fr")
|
||||
|
||||
if got := svc.T("missing.status"); got != "Common status" {
|
||||
t.Fatalf("T(missing.status) = %q, want %q", got, "Common status")
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceDebug(t *testing.T) {
|
||||
svc, err := New()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue