[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #49
2 changed files with 22 additions and 3 deletions
11
service.go
11
service.go
|
|
@ -330,11 +330,16 @@ func (s *Service) T(messageID string, args ...any) string {
|
|||
return result
|
||||
}
|
||||
|
||||
func (s *Service) resolveWithFallback(messageID string, data any) string {
|
||||
// resolveDirect performs exact-key lookup in the current language and fallback language.
|
||||
func (s *Service) resolveDirect(messageID string, data any) string {
|
||||
if text := s.tryResolve(s.currentLang, messageID, data); text != "" {
|
||||
return text
|
||||
}
|
||||
if text := s.tryResolve(s.fallbackLang, messageID, data); text != "" {
|
||||
return s.tryResolve(s.fallbackLang, messageID, data)
|
||||
}
|
||||
|
||||
func (s *Service) resolveWithFallback(messageID string, data any) string {
|
||||
if text := s.resolveDirect(messageID, data); text != "" {
|
||||
return text
|
||||
}
|
||||
if core.Contains(messageID, ".") {
|
||||
|
|
@ -543,7 +548,7 @@ func (s *Service) Raw(messageID string, args ...any) string {
|
|||
if len(args) > 0 {
|
||||
data = args[0]
|
||||
}
|
||||
text := s.resolveWithFallback(messageID, data)
|
||||
text := s.resolveDirect(messageID, data)
|
||||
if text == "" {
|
||||
return s.handleMissingKey(messageID, args)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,6 +126,20 @@ func TestServiceRaw(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestServiceRaw_DoesNotUseCommonFallbacks(t *testing.T) {
|
||||
svc, err := New()
|
||||
if err != nil {
|
||||
t.Fatalf("New() failed: %v", err)
|
||||
}
|
||||
|
||||
svc.messages["en"]["common.action.status"] = Message{Text: "Common status"}
|
||||
|
||||
got := svc.Raw("missing.status")
|
||||
if got != "missing.status" {
|
||||
t.Errorf("Raw(missing.status) = %q, want key returned", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceModes(t *testing.T) {
|
||||
svc, err := New()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue