[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find features de... #142
2 changed files with 42 additions and 2 deletions
12
service.go
12
service.go
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue