[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find features de... #135

Merged
Virgil merged 1 commit from agent/read---spec-code-core-go-i18n-rfc-md-ful into dev 2026-04-02 06:17:52 +00:00
2 changed files with 18 additions and 2 deletions

View file

@ -40,7 +40,7 @@ type Option func(*Service)
// WithFallback sets the fallback language for missing translations.
func WithFallback(lang string) Option {
return func(s *Service) { s.fallbackLang = lang }
return func(s *Service) { s.fallbackLang = normalizeLanguageTag(lang) }
}
// WithFormality sets the default formality level.
@ -290,7 +290,7 @@ func (s *Service) SetMode(m Mode) { s.mu.Lock(); s.mode = m; s.mu.Unlo
func (s *Service) Mode() Mode { s.mu.RLock(); defer s.mu.RUnlock(); return s.mode }
func (s *Service) SetFormality(f Formality) { s.mu.Lock(); s.formality = f; s.mu.Unlock() }
func (s *Service) Formality() Formality { s.mu.RLock(); defer s.mu.RUnlock(); return s.formality }
func (s *Service) SetFallback(lang string) { s.mu.Lock(); s.fallbackLang = lang; s.mu.Unlock() }
func (s *Service) SetFallback(lang string) { s.mu.Lock(); s.fallbackLang = normalizeLanguageTag(lang); s.mu.Unlock() }
func (s *Service) Fallback() string {
s.mu.RLock()
defer s.mu.RUnlock()

View file

@ -370,6 +370,22 @@ func TestServiceFallback(t *testing.T) {
}
}
func TestServiceFallbackNormalisesLanguageTag(t *testing.T) {
svc, err := New(WithFallback("fr_CA"))
if err != nil {
t.Fatalf("New() failed: %v", err)
}
if got, want := svc.Fallback(), "fr-CA"; got != want {
t.Fatalf("WithFallback(fr_CA) = %q, want %q", got, want)
}
svc.SetFallback("en_US")
if got, want := svc.Fallback(), "en-US"; got != want {
t.Fatalf("SetFallback(en_US) = %q, want %q", got, want)
}
}
func TestServiceMessageFallbackUsesBaseLanguageTagBeforeConfiguredFallback(t *testing.T) {
svc, err := NewWithLoader(messageBaseFallbackLoader{})
if err != nil {