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
@@ -0,0 +1,41 @@
|
||||
import type { AdminText } from '../admin-i18n/define.js'
|
||||
import type { AdminTextKey } from '../admin-i18n/texts/index.js'
|
||||
|
||||
import { adminTexts } from '../admin-i18n/texts/index.js'
|
||||
|
||||
/** A label as Payload takes it: one string, or one string per language. */
|
||||
export type IntegrationLabel = AdminText | Record<string, string> | string
|
||||
|
||||
/** The label in `language`, falling back to English, then to any language. */
|
||||
export function resolveLabel(label: IntegrationLabel | undefined, language: string | undefined): string {
|
||||
if (!label) {return ''}
|
||||
if (typeof label === 'string') {return label}
|
||||
const map = label as Record<string, string>
|
||||
return map[language ?? 'en'] ?? map.en ?? Object.values(map)[0] ?? ''
|
||||
}
|
||||
|
||||
/** Status codes whose message has its own text — shown in the editor's language. */
|
||||
export const STATUS_CODE_TEXTS: Record<string, AdminTextKey> = {
|
||||
'bad-response': 'statusTurnstileBadResponse',
|
||||
'graph-unavailable': 'statusEmailGraphUnavailable',
|
||||
'internal-error': 'statusTurnstileInternalError',
|
||||
'invalid-input-secret': 'statusTurnstileInvalidSecret',
|
||||
'missing-input-secret': 'statusTurnstileMissingSecret',
|
||||
'missing-secret': 'statusTurnstileMissingSecret',
|
||||
'network-error': 'statusTurnstileNetworkError',
|
||||
}
|
||||
|
||||
type I18nLike = { language?: string; t?: (key: never, vars?: Record<string, unknown>) => string } | undefined
|
||||
|
||||
/**
|
||||
* One plugin text on the server: through `i18n.t` when Payload's i18n is there
|
||||
* (so a project's own translation wins), else the plugin's English text.
|
||||
*/
|
||||
export function serverText(i18n: I18nLike, key: AdminTextKey, vars: Record<string, unknown> = {}): string {
|
||||
if (i18n?.t) {
|
||||
const out = i18n.t(`ipal:${key}` as never, vars)
|
||||
if (out && out !== `ipal:${key}` && out !== key) {return out}
|
||||
}
|
||||
const lang = i18n?.language === 'pl' ? 'pl' : 'en'
|
||||
return adminTexts[lang][key].replace(/\{\{(\w+)\}\}/g, (_, name: string) => String((vars[name] as number | string | undefined) ?? ''))
|
||||
}
|
||||
Reference in New Issue
Block a user