diff --git a/service.go b/service.go index 6f21ecd..c4fd078 100644 --- a/service.go +++ b/service.go @@ -440,7 +440,7 @@ func (s *Service) getEffectiveContextGenderLocationAndFormality(data any) (strin if m, ok := data.(map[string]any); ok { var context string var gender string - var location string + location := s.location formality := s.formality if v, ok := m["Context"].(string); ok { context = core.Trim(v) diff --git a/service_test.go b/service_test.go index e32cce9..47df379 100644 --- a/service_test.go +++ b/service_test.go @@ -349,6 +349,22 @@ func TestServiceTranslationContextExtrasInLookup(t *testing.T) { } } +func TestServiceDefaultLocationAppliesToMapData(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", map[string]any{}); got != "welcome aboard" { + t.Errorf("T(welcome, map[]) with default location = %q, want %q", got, "welcome aboard") + } +} + func TestServiceSubjectCountPlurals(t *testing.T) { svc, err := New() if err != nil {