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
@@ -1,5 +1,6 @@
|
||||
import type { Field, RelationshipField } from 'payload'
|
||||
|
||||
import type { AdminText } from '../admin-i18n/index.js'
|
||||
import type { ContentOption } from './types.js'
|
||||
|
||||
import { archiveFieldName } from './types.js'
|
||||
@@ -16,17 +17,32 @@ import { archiveFieldName } from './types.js'
|
||||
*/
|
||||
export function buildArchiveFields(content: ContentOption, pagesSlug: string): Field[] {
|
||||
return content.collections.map((collection): RelationshipField => {
|
||||
const label = collection.label ?? collection.slug
|
||||
const name = collectionName(collection.label, collection.slug)
|
||||
|
||||
return {
|
||||
name: archiveFieldName(collection.slug),
|
||||
type: 'relationship',
|
||||
admin: {
|
||||
description: `Page listing ${label}. Its slug becomes the URL segment for entries (e.g. /pl/artykuly/moj-wpis).`,
|
||||
description: {
|
||||
en: 'Page that lists the entries; its address (URL) starts the address of each entry.',
|
||||
pl: 'Strona z listą wpisów; jej adres (URL) rozpoczyna adres każdego wpisu.',
|
||||
},
|
||||
},
|
||||
label: `${label} — archive page`,
|
||||
label: { en: `${name.en} archive`, pl: `Archiwum: ${name.pl}` },
|
||||
maxDepth: 1,
|
||||
relationTo: pagesSlug,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* The collection's name in each admin language: the project's `label` (a
|
||||
* string, or `{ en, pl }`), else the slug made readable (`blog-posts` → "Blog posts").
|
||||
*/
|
||||
function collectionName(label: AdminText | string | undefined, slug: string): AdminText {
|
||||
if (label && typeof label === 'object') {return { en: label.en, pl: label.pl || label.en }}
|
||||
if (typeof label === 'string' && label.trim()) {return { en: label, pl: label }}
|
||||
const words = slug.replace(/[-_]+/g, ' ').replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase().trim()
|
||||
const readable = words.charAt(0).toUpperCase() + words.slice(1)
|
||||
return { en: readable, pl: readable }
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { AdminText } from '../admin-i18n/index.js'
|
||||
|
||||
/**
|
||||
* A collection whose entries live under an archive page, e.g. blog posts at
|
||||
* /pl/artykuly/moj-post.
|
||||
@@ -10,7 +12,7 @@
|
||||
*/
|
||||
export type ContentCollectionOption = {
|
||||
/** Admin label for the archive assignment. Defaults to the slug. */
|
||||
label?: string
|
||||
label?: AdminText | string
|
||||
/** Entries per page in listings. Defaults to 10. */
|
||||
perPage?: number
|
||||
/** Slug of the client's collection, e.g. 'posts'. */
|
||||
|
||||
Reference in New Issue
Block a user