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

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

View file

@ -475,14 +475,22 @@ func (s *Service) getEffectiveContextGenderLocationAndFormality(data any) (strin
if formality == FormalityNeutral {
formality = s.formality
}
return ctx.ContextString(), ctx.GenderString(), ctx.LocationString(), formality
location := ctx.LocationString()
if location == "" {
location = s.location
}
return ctx.ContextString(), ctx.GenderString(), location, formality
}
if subj, ok := data.(*Subject); ok && subj != nil {
formality := subj.formality
if formality == FormalityNeutral {
formality = s.formality
}
return "", subj.gender, subj.location, formality
location := subj.location
if location == "" {
location = s.location
}
return "", subj.gender, location, formality
}
if m, ok := data.(map[string]any); ok {
var context string

View file

@ -626,6 +626,38 @@ func TestServiceDefaultLocationContext(t *testing.T) {
}
}
func TestServiceDefaultLocationAppliesToTranslationContext(t *testing.T) {
svc, err := New()
if err != nil {
t.Fatalf("New() failed: %v", err)
}
svc.AddMessages("en", map[string]string{
"welcome._greeting._workspace": "hello from workspace",
})
svc.SetLocation("workspace")
if got := svc.T("welcome", C("greeting")); got != "hello from workspace" {
t.Errorf("T(welcome, C(greeting)) with default location = %q, want %q", got, "hello from workspace")
}
}
func TestServiceDefaultLocationAppliesToSubject(t *testing.T) {
svc, err := New()
if err != nil {
t.Fatalf("New() failed: %v", err)
}
svc.AddMessages("en", map[string]string{
"welcome._workspace": "welcome aboard",
})
svc.SetLocation("workspace")
if got := svc.T("welcome", S("user", "Alice")); got != "welcome aboard" {
t.Errorf("T(welcome, Subject) with default location = %q, want %q", got, "welcome aboard")
}
}
func TestServiceTranslationContextExtrasInTemplates(t *testing.T) {
svc, err := New()
if err != nil {