Form files: the visitor is told when the problem is the file — why and what to do; UTF-8 file names

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-13 16:51:05 +01:00
co-authored by Claude Fable 5.2
parent b6f9f34705
commit 97202ee03e
18 changed files with 335 additions and 128 deletions
+12 -7
View File
@@ -61,17 +61,22 @@ per language.
With `forms.attachments` ([forms.md](./forms.md) "Files") the **Files** group of Form messages holds:
Each one tells the visitor that the problem is the file, why, and what to do next.
| Key | Placeholders | English default |
|---|---|---|
| `fileTooLarge` | `{file}`, `{max}` (MB) | `"{file}" is too large. The limit is {max} MB.` |
| `fileType` | `{file}`, `{types}` | `"{file}" is not an accepted file type. Accepted: {types}.` |
| `fileCount` | `{field}`, `{max}` | `Attach at most {max} files in "{field}".` |
| `fileNotSent` | — | `We could not send your file. Try again, or send it by e-mail.` |
| `fileTooLarge` | `{file}`, `{max}` (MB) | `The file "{file}" is too large. Choose a file of up to {max} MB.` |
| `fileType` | `{file}`, `{types}` | `The file "{file}" is in a format we do not accept. Choose one of: {types}.` |
| `fileRefused` | `{file}`, `{types}` | `The file "{file}" was refused: it is a program or an archive, it holds macros, or its content does not match its type. Choose another file ({types}).` |
| `fileCount` | `{field}`, `{max}` | `Too many files in "{field}". Remove some: the limit is {max}.` |
| `fileNotSent` | `{file}` | `We could not send the file "{file}". Choose a smaller file or another format and try again.` |
| `fileOptional` | — | `You can also send the form without the file.` — added to the five above when the File field is not required |
| `fileRemove` | `{file}` | `Remove {file}` |
Polish defaults ship too; any other language is filled in the panel. `resolveFormMessage` maps
`kind: 'file_too_large' | 'file_type' | 'file_count'` and `reason: 'delivery'` to them; a texts object without these
keys falls back to `validation` / `error`.
Polish defaults ship too; any other language is filled in the panel (an empty field falls back to English there).
`resolveFormMessage` maps `kind: 'file_too_large' | 'file_type' | 'file_refused' | 'file_count'` and
`reason: 'delivery'` to them and appends `fileOptional` when the result says `optional`; a texts object without
these keys falls back to `validation` / `error`. The result carries `field`, so the message shows at the File field.
## {field} interpolation