diff --git a/loader.go b/loader.go index 96cf45f..fc6336d 100644 --- a/loader.go +++ b/loader.go @@ -132,6 +132,9 @@ func flattenWithGrammar(prefix string, data map[string]any, out map[string]Messa if gerund, ok := v["gerund"].(string); ok { forms.Gerund = gerund } + if forms.Past == "" || forms.Gerund == "" { + continue + } grammar.Verbs[core.Lower(verbName)] = forms continue } diff --git a/loader_test.go b/loader_test.go index 2cfa9bc..c2d3d86 100644 --- a/loader_test.go +++ b/loader_test.go @@ -132,6 +132,12 @@ func TestFlattenWithGrammar(t *testing.T) { "past": "tested", "gerund": "testing", }, + "partial_past": map[string]any{ + "past": "partialed", + }, + "partial_gerund": map[string]any{ + "gerund": "partialing", + }, "publish_draft": map[string]any{ "base": "publish", "past": "published", @@ -201,6 +207,18 @@ func TestFlattenWithGrammar(t *testing.T) { if _, ok := grammar.Verbs["publish_draft"]; ok { t.Error("verb should be stored under explicit base, not JSON key") } + if _, ok := grammar.Verbs["partial_past"]; ok { + t.Error("incomplete verb entry with only past should be skipped") + } + if _, ok := grammar.Verbs["partial_gerund"]; ok { + t.Error("incomplete verb entry with only gerund should be skipped") + } + if _, ok := messages["gram.verb.partial_past"]; ok { + t.Error("gram.verb.partial_past should not be flattened into messages") + } + if _, ok := messages["gram.verb.partial_gerund"]; ok { + t.Error("gram.verb.partial_gerund should not be flattened into messages") + } // Noun extracted if n, ok := grammar.Nouns["widget"]; !ok {