diff --git a/pkg/i18n/compose_test.go b/pkg/i18n/compose_test.go index 0428bb21..0a95e9dd 100644 --- a/pkg/i18n/compose_test.go +++ b/pkg/i18n/compose_test.go @@ -248,6 +248,11 @@ func composeIntent(intent Intent, subject *Subject) *Composed { // can compose the same strings as the intent templates. // This turns the intents definitions into a comprehensive test suite. func TestGrammarComposition_MatchesIntents(t *testing.T) { + // Clear locale env vars to ensure British English fallback (en-GB) + t.Setenv("LANG", "") + t.Setenv("LC_ALL", "") + t.Setenv("LC_MESSAGES", "") + // Test subjects for validation subjects := []struct { noun string @@ -428,6 +433,11 @@ func TestProgress_AllIntentVerbs(t *testing.T) { // TestPastTense_AllIntentVerbs ensures PastTense works for all intent verbs. func TestPastTense_AllIntentVerbs(t *testing.T) { + // Clear locale env vars to ensure British English fallback (en-GB) + t.Setenv("LANG", "") + t.Setenv("LC_ALL", "") + t.Setenv("LC_MESSAGES", "") + expected := map[string]string{ // Destructive "delete": "deleted", @@ -499,6 +509,11 @@ func TestPastTense_AllIntentVerbs(t *testing.T) { // TestGerund_AllIntentVerbs ensures Gerund works for all intent verbs. func TestGerund_AllIntentVerbs(t *testing.T) { + // Clear locale env vars to ensure British English fallback (en-GB) + t.Setenv("LANG", "") + t.Setenv("LC_ALL", "") + t.Setenv("LC_MESSAGES", "") + expected := map[string]string{ // Destructive "delete": "deleting", diff --git a/pkg/i18n/i18n_test.go b/pkg/i18n/i18n_test.go index a02bbac7..920bbd9b 100644 --- a/pkg/i18n/i18n_test.go +++ b/pkg/i18n/i18n_test.go @@ -44,10 +44,15 @@ func TestTranslateWithArgs(t *testing.T) { } func TestSetLanguage(t *testing.T) { + // Clear locale env vars to ensure fallback to en-GB + t.Setenv("LANG", "") + t.Setenv("LC_ALL", "") + t.Setenv("LC_MESSAGES", "") + svc, err := New() require.NoError(t, err) - // Default is en-GB + // Default is en-GB (when no system locale detected) assert.Equal(t, "en-GB", svc.Language()) // Setting invalid language should error diff --git a/pkg/i18n/types.go b/pkg/i18n/types.go index ac17aaaa..a84db9bd 100644 --- a/pkg/i18n/types.go +++ b/pkg/i18n/types.go @@ -408,6 +408,16 @@ var irregularVerbs = map[string]VerbForms{ "cancel": {Past: "cancelled", Gerund: "cancelling"}, "travel": {Past: "travelled", Gerund: "travelling"}, "label": {Past: "labelled", Gerund: "labelling"}, "model": {Past: "modelled", Gerund: "modelling"}, "level": {Past: "levelled", Gerund: "levelling"}, + // British English spellings + "format": {Past: "formatted", Gerund: "formatting"}, + "analyse": {Past: "analysed", Gerund: "analysing"}, + "organise": {Past: "organised", Gerund: "organising"}, + "recognise": {Past: "recognised", Gerund: "recognising"}, + "realise": {Past: "realised", Gerund: "realising"}, + "customise": {Past: "customised", Gerund: "customising"}, + "optimise": {Past: "optimised", Gerund: "optimising"}, + "initialise": {Past: "initialised", Gerund: "initialising"}, + "synchronise": {Past: "synchronised", Gerund: "synchronising"}, } // noDoubleConsonant contains multi-syllable verbs that don't double the final consonant.