From 145251481b40cddce31bb47c34f3a41b8323c6f2 Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Wed, 4 Nov 2026 11:42:48 +0100 Subject: [PATCH] fix(phrasebook): translate the pl string message and the numeric min/max lines (quick-261104-fx1) - pl validation.yaml string line is Polish (Winter's pl file leaves it in English); the header notes the deliberate divergence - pl validate.yaml min and max use Winter's numeric wording, since those keys only serve numeric and integer bounds --- modules/lagoon/validate_test.go | 31 ++++++++++++++++++++++ modules/phrasebook/lang/pl/validate.yaml | 4 +-- modules/phrasebook/lang/pl/validation.yaml | 4 ++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/modules/lagoon/validate_test.go b/modules/lagoon/validate_test.go index 15c248e4..0baf47fe 100644 --- a/modules/lagoon/validate_test.go +++ b/modules/lagoon/validate_test.go @@ -541,3 +541,34 @@ func TestValidateLengthWithoutStringRuleTranslated(t *testing.T) { } } } + +// TestValidatePolishStringAndNumericLines: the pl request catalog answers a +// string failure in Polish, and lagoon.Validate's numeric min and max +// failures read as numbers, not character counts. +func TestValidatePolishStringAndNumericLines(t *testing.T) { + rules := []RequestRule{{Field: "s", Rules: ParseRules("string")}} + if got := mustValidate(t, inLocale("pl"), map[string]any{"s": 123}, rules)["s"]; !slices.Equal(got, []string{"s musi być ciągiem znaków."}) { + t.Fatalf("pl string = %q", got) + } + if got := mustValidate(t, inLocale("en"), map[string]any{"s": 123}, rules)["s"]; !slices.Equal(got, []string{"The s must be a string."}) { + t.Fatalf("en string = %q", got) + } + tr := requestTranslator(t) + cases := []struct { + rule string + value any + want string + }{ + {"integer|max:10", 11, "views nie może być większy niż 10."}, + {"integer|min:0", -1, "views musi być nie mniejszy od 0."}, + } + for _, tc := range cases { + errs, err := Validate(inLocale("pl"), nil, nil, map[string]string{"views": tc.rule}, map[string]any{"views": tc.value}, tr) + if err != nil { + t.Fatal(err) + } + if got := errs["views"]; !slices.Equal(got, []string{tc.want}) { + t.Fatalf("%q on %v = %q, want %q", tc.rule, tc.value, got, tc.want) + } + } +} diff --git a/modules/phrasebook/lang/pl/validate.yaml b/modules/phrasebook/lang/pl/validate.yaml index 396f3bab..fb32f817 100644 --- a/modules/phrasebook/lang/pl/validate.yaml +++ b/modules/phrasebook/lang/pl/validate.yaml @@ -7,8 +7,8 @@ confirmed: "Potwierdzenie :attribute nie zgadza się." different: ":attribute oraz :other muszą się różnić." integer: ":attribute musi być liczbą całkowitą." numeric: ":attribute musi być liczbą." -max: ":attribute nie może być dłuższy niż :max znaków." -min: ":attribute musi mieć przynajmniej :min znaków." +max: ":attribute nie może być większy niż :max." +min: ":attribute musi być nie mniejszy od :min." oneof: "Zaznaczony :attribute jest nieprawidłowy." mimes: ":attribute musi być plikiem typu :values." string: ":attribute musi być ciągiem znaków." diff --git a/modules/phrasebook/lang/pl/validation.yaml b/modules/phrasebook/lang/pl/validation.yaml index 8f6a138c..0f6a25f1 100644 --- a/modules/phrasebook/lang/pl/validation.yaml +++ b/modules/phrasebook/lang/pl/validation.yaml @@ -1,6 +1,8 @@ # Port of WinterCMS modules/system/lang/pl/validation.php (Laravel validator # messages). Text is copied verbatim; keys absent from this locale fall back to # app.fallback_locale as in Winter. Loaded as lagoon::validation.* +# `string`, which Winter's pl file leaves in English, is translated here, so a +# pl request gets a Polish line where the PHP backend answers in English. accepted: ":attribute musi zostać zaakceptowany." active_url: ":attribute jest nieprawidłowym adresem URL." after: ":attribute musi być datą późniejszą od :date." @@ -61,7 +63,7 @@ size: file: ":attribute musi mieć :size kilobajtów." string: ":attribute musi mieć :size znaków." array: ":attribute musi zawierać :size elementów." -string: "The :attribute must be a string." +string: ":attribute musi być ciągiem znaków." timezone: ":attribute musi być prawidłową strefą czasową." unique: "Taki :attribute już występuje." url: "Format :attribute jest nieprawidłowy."