[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #85

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

View file

@ -472,11 +472,32 @@ func (s *Service) getEffectiveContextGenderLocationAndFormality(data any) (strin
}
func (s *Service) getEffectiveContextExtra(data any) map[string]any {
ctx, ok := data.(*TranslationContext)
if !ok || ctx == nil || len(ctx.Extra) == 0 {
switch v := data.(type) {
case *TranslationContext:
if v == nil || len(v.Extra) == 0 {
return nil
}
return v.Extra
case map[string]any:
if len(v) == 0 {
return nil
}
extra := make(map[string]any, len(v))
for key, value := range v {
switch key {
case "Context", "Gender", "Location", "Formality":
continue
default:
extra[key] = value
}
}
if len(extra) == 0 {
return nil
}
return extra
default:
return nil
}
return ctx.Extra
}
func (s *Service) getEffectiveFormality(data any) Formality {

View file

@ -349,6 +349,31 @@ func TestServiceTranslationContextExtrasInLookup(t *testing.T) {
}
}
func TestServiceMapContextExtrasInLookup(t *testing.T) {
svc, err := New()
if err != nil {
t.Fatalf("New() failed: %v", err)
}
svc.AddMessages("en", map[string]string{
"welcome._greeting": "hello",
"welcome._greeting._region._europe": "bonjour",
"welcome._greeting._region._americas": "howdy",
})
if got := svc.T("welcome", map[string]any{"Context": "greeting"}); got != "hello" {
t.Errorf("T(welcome, map[Context:greeting]) = %q, want %q", got, "hello")
}
if got := svc.T("welcome", map[string]any{"Context": "greeting", "region": "europe"}); got != "bonjour" {
t.Errorf("T(welcome, map[Context:greeting region:europe]) = %q, want %q", got, "bonjour")
}
if got := svc.T("welcome", map[string]any{"Context": "greeting", "region": "americas"}); got != "howdy" {
t.Errorf("T(welcome, map[Context:greeting region:americas]) = %q, want %q", got, "howdy")
}
}
func TestServiceDefaultLocationAppliesToMapData(t *testing.T) {
svc, err := New()
if err != nil {