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
This commit is contained in:
Jakub Zych
2026-11-04 11:42:48 +01:00
parent 335f8e608e
commit 145251481b
3 changed files with 36 additions and 3 deletions

View File

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

View File

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

View File

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