fix(i18n): add British English verb forms and fix locale-dependent tests (#328)

* fix(i18n): add British English verb forms and fix locale-dependent tests

- Add British English spellings for verbs: format, analyse, organise,
  recognise, realise, customise, optimise, initialise, synchronise
- Clear LANG/LC_ALL/LC_MESSAGES env vars in tests to ensure consistent
  en-GB fallback behavior regardless of system locale
- Fixes qa test failures on systems with en_US locale

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* style: gofmt types.go

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude <developers@lethean.io>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Vi 2026-02-05 10:05:57 +00:00 committed by GitHub
parent ea79011871
commit 18847be9cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 1 deletions

View file

@ -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",

View file

@ -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

View file

@ -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.