Admin panel in English and Polish, reworded per docs/dev/admin-ux.md
- admin-i18n module: AdminText { en, pl }, component texts under the ipal
namespace (project translations win), en + pl admin languages when the
project sets none (project's supportedLanguages wins)
- every plugin label, description, option, tab and group as { en, pl };
explicit labels instead of auto-labels; sentence case; glossary terms
- visible renames (slugs, names, data unchanged): Cookie banner, Form
messages, Privacy group, Search engines, Maintenance, Spam protection,
E-mail sending, stats nav link Overview (hidden without access)
- Polish visitor defaults by page locale: cookie banner, form messages,
validators, lightbox, accessibility widget; {field} uses the label
- fixes: e-mail status banner used Turnstile wording; developer words and
env var names out of editor messages; stats numbers/dates in the admin
language; test e-mail no longer says ipal-kit
- test/adminUx.test.ts: length limits, en + pl present, no developer words
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
eeac33ed2f
commit
6b46bc0c14
@@ -67,6 +67,8 @@ export type SubmitFailure =
|
||||
field?: string
|
||||
/** What was wrong with it. */
|
||||
kind?: 'invalid_format' | 'required' | 'too_long' | 'unknown_fields'
|
||||
/** The offending field's label in the page's language — what the visitor sees. Absent when the field has none. */
|
||||
label?: string
|
||||
reason: 'validation'
|
||||
success: false
|
||||
}
|
||||
@@ -141,11 +143,13 @@ export async function submitForm({
|
||||
if (validation.reason === 'consent') {
|
||||
return { field: validation.field, reason: 'consent', success: false }
|
||||
}
|
||||
const label = validation.field ? await fieldLabel(payload, formId, validation.field, locale) : undefined
|
||||
return {
|
||||
reason: 'validation',
|
||||
success: false,
|
||||
...(validation.field ? { field: validation.field } : {}),
|
||||
...(validation.kind ? { kind: validation.kind } : {}),
|
||||
...(label ? { label } : {}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,3 +174,23 @@ export async function submitForm({
|
||||
return { reason: 'error', success: false }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The label of one form field in the page's language, so a message names the
|
||||
* field the way the visitor sees it ("E-mail address", not "email"). Only read
|
||||
* when a submission fails; never throws.
|
||||
*/
|
||||
async function fieldLabel(payload: BasePayload, formId: string, name: string, locale?: string): Promise<string | undefined> {
|
||||
try {
|
||||
const form = (await payload.findByID({
|
||||
id: formId,
|
||||
collection: 'forms',
|
||||
depth: 0,
|
||||
...(locale ? { locale: locale as never } : {}),
|
||||
})) as { fields?: { label?: unknown; name?: unknown }[] }
|
||||
const label = form.fields?.find((f) => f.name === name)?.label
|
||||
return typeof label === 'string' && label.trim() ? label.trim() : undefined
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user