From 524e7eac8ba7c9078707b17dbe5e84357961f2d6 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 23:34:03 +0000 Subject: [PATCH] feat(validate): localise article validation prompts Co-Authored-By: Virgil --- validate.go | 11 +++++++++++ validate_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/validate.go b/validate.go index c7f3bec..ff5aa9e 100644 --- a/validate.go +++ b/validate.go @@ -44,6 +44,17 @@ type IrregularResult struct { // articlePrompt builds a fill-in-the-blank prompt for article prediction. func articlePrompt(noun string) string { + return articlePromptForLang(currentLangForGrammar(), noun) +} + +func articlePromptForLang(lang, noun string) string { + noun = core.Trim(noun) + if isFrenchLanguage(lang) { + return core.Sprintf( + "Complete with the correct article (le/la/l'/les/un/une/des): ___ %s. Answer with just the article:", + noun, + ) + } return core.Sprintf( "Complete with the correct article (a/an/the): ___ %s. Answer with just the article:", noun, diff --git a/validate_test.go b/validate_test.go index d5b1718..856b3dd 100644 --- a/validate_test.go +++ b/validate_test.go @@ -327,6 +327,30 @@ func TestArticlePrompt(t *testing.T) { } } +func TestArticlePromptFrenchLocale(t *testing.T) { + prev := Default() + svc, err := New() + if err != nil { + t.Fatalf("New() failed: %v", err) + } + SetDefault(svc) + t.Cleanup(func() { + SetDefault(prev) + }) + + if err := SetLanguage("fr"); err != nil { + t.Fatalf("SetLanguage(fr) failed: %v", err) + } + + prompt := articlePrompt("livre") + if !contains(prompt, "livre") { + t.Errorf("prompt should contain the noun: %q", prompt) + } + if !contains(prompt, "le/la/l'/les/un/une/des") { + t.Errorf("prompt should mention French article options: %q", prompt) + } +} + func TestIrregularPrompt(t *testing.T) { prompt := irregularPrompt("swim", "past participle") if !contains(prompt, "'swim'") { -- 2.45.3