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:
Radosław Smoliński
2026-10-27 15:46:25 +01:00
co-authored by Claude Opus 5.5
parent eeac33ed2f
commit 6b46bc0c14
108 changed files with 2806 additions and 981 deletions
+32
View File
@@ -0,0 +1,32 @@
import type { Config } from 'payload'
import { en } from 'payload/i18n/en'
import { pl } from 'payload/i18n/pl'
import { deepMergeSimple } from 'payload/shared'
import { adminTexts } from './texts/index.js'
/**
* Admin languages and the plugin's component texts.
*
* - `i18n.supportedLanguages`: English and Polish when the project set none;
* a project's own list always wins.
* - `i18n.translations`: the plugin's texts under the `ipal` namespace, with the
* project's translations merged on top (the project wins key by key). A
* language the plugin has no texts for gets the English ones.
*/
export function applyAdminI18n(config: Config): Config {
const supportedLanguages = config.i18n?.supportedLanguages ?? { en, pl }
const plugin: Record<string, { ipal: Record<string, string> }> = {}
for (const lang of Object.keys(supportedLanguages)) {
plugin[lang] = { ipal: lang === 'pl' ? adminTexts.pl : adminTexts.en }
}
return {
...config,
i18n: {
...config.i18n,
supportedLanguages,
translations: deepMergeSimple(plugin, (config.i18n?.translations ?? {}) as Record<string, unknown>),
},
}
}
+14
View File
@@ -0,0 +1,14 @@
/** A visible admin string in every language the plugin ships. Payload accepts it as `label`, `description`, option `label`, tab `label`, `admin.group`. */
export type AdminText = { en: string; pl: string }
/** Languages the plugin ships admin texts in. */
export const ADMIN_LANGUAGES = ['en', 'pl'] as const
export type AdminLanguage = (typeof ADMIN_LANGUAGES)[number]
/**
* Declares one group of component texts. The Polish set must have exactly the
* English keys, so a missing translation is a type error.
*/
export function defineTexts<T extends Record<string, string>>(texts: { en: T; pl: Record<keyof T, string> }) {
return texts
}
+6
View File
@@ -0,0 +1,6 @@
// Client-safe: types, texts and helpers. The config transform (applyAdminI18n) lives in apply.ts.
export type { AdminLanguage, AdminText } from './define.js'
export { ADMIN_LANGUAGES, defineTexts } from './define.js'
export { formatDateTime, formatNumber, ipalT } from './t.js'
export { adminTexts } from './texts/index.js'
export type { AdminTextKey } from './texts/index.js'
+19
View File
@@ -0,0 +1,19 @@
import type { AdminTextKey } from './texts/index.js'
type TFunction = (key: never, vars?: Record<string, unknown>) => string
/**
* Reads one plugin text through Payload's `t` (from `useTranslation()` in client
* components, `i18n.t` in server components), so a project's own
* `i18n.translations.<lang>.ipal.<key>` wins over the plugin's.
*/
export function ipalT(t: TFunction, key: AdminTextKey, vars?: Record<string, unknown>): string {
return t(`ipal:${key}` as never, vars)
}
/** Number in the admin language's format (1 234 in Polish, 1,234 in English). */
export const formatNumber = (n: number, language: string) => new Intl.NumberFormat(language).format(n)
/** Date and time in the admin language's format. */
export const formatDateTime = (iso: string, language: string, timeZone?: string) =>
new Intl.DateTimeFormat(language, { dateStyle: 'medium', timeStyle: 'short', ...(timeZone ? { timeZone } : {}) }).format(new Date(iso))
+7
View File
@@ -0,0 +1,7 @@
import { defineTexts } from '../define.js'
/** Admin component texts — consent. Placeholders use Payload's {{name}} syntax. */
export const consentTexts = defineTexts({
en: {},
pl: {},
})
+112
View File
@@ -0,0 +1,112 @@
import { defineTexts } from '../define.js'
/**
* Admin component texts — content (statistics, SEO hints, row labels).
* Placeholders use Payload's {{name}} syntax. Plural sets end in One / Few /
* Many / Other (Intl.PluralRules categories); English uses One and Other.
*/
export const contentTexts = defineTexts({
en: {
// Statistics: nav link, view, widget, chart
statsBack: 'Back to statistics',
statsChartDay: '{{day}} · Visits: {{visits}} · Page views: {{views}}',
statsChartTable: 'Table',
statsColDay: 'Day',
statsColDevice: 'Device',
statsColEntryPage: 'Entry page',
statsColLastVisit: 'Last visit',
statsColPage: 'Page',
statsColReferrer: 'Referrer',
statsColViews: 'Views',
statsColVisitor: 'Visitor',
statsConsentedVisits: 'Visits with analytics consent',
statsDeviceDesktop: 'Desktop',
statsDeviceMobile: 'Mobile',
statsDeviceTablet: 'Tablet',
statsDirect: '(direct)',
statsFrom: 'from {{referrer}}',
statsIntro: 'Last 30 days, counted without cookies and without storing IP addresses.',
statsNavLink: 'Overview',
statsNoAccess: 'You do not have access to statistics.',
statsNoData: 'No data yet. It appears after the first visits.',
statsNoVisitors: 'No visitor has accepted analytics cookies yet.',
statsPagesFew: '{{count}} pages',
statsPagesMany: '{{count}} pages',
statsPagesOne: '{{count}} page',
statsPagesOther: '{{count}} pages',
statsPagesPerVisit: 'Pages per visit',
statsPageViews: 'Page views',
statsSinglePageVisits: 'Single-page visits',
statsTitle: 'Statistics',
statsUnknownDevice: 'Unknown device',
statsVisitorErase: 'To erase this visitor’s data, filter the visits list by this visitor ID and delete the results.',
statsVisitorHeading: 'Visitor',
statsVisitorHistory: 'Visitor history (with consent)',
statsVisitorLink: 'Visitor {{id}}',
statsVisitorVisitsFew: '{{count}} visits recorded with analytics consent.',
statsVisitorVisitsMany: '{{count}} visits recorded with analytics consent.',
statsVisitorVisitsOne: '{{count}} visit recorded with analytics consent.',
statsVisitorVisitsOther: '{{count}} visits recorded with analytics consent.',
statsVisits: 'Visits',
statsVisitsPerDay: 'Visits per day',
statsWidgetLink: 'All statistics',
statsWidgetSummary: 'Last 30 days · Visits: {{visits}} · Page views: {{views}}',
// SEO: description check under the search result description
seoDescEmpty: 'Empty. The page uses the site description, the same as every other page.',
seoDescEmptyAutoFill: 'Empty. On save it is filled from the page content; writing your own is better.',
seoDescSameAs: 'Same description as “{{name}}”. Google ignores a description repeated across pages; make each one unique.',
seoDescSameAsSite: 'Same as the site description. Google ignores a description repeated across pages; write one for this page.',
// Array rows without a name
rowLabelItem: 'Item',
},
pl: {
rowLabelItem: 'Element',
seoDescEmpty: 'Puste. Strona użyje opisu witryny, takiego samego jak na innych stronach.',
seoDescEmptyAutoFill: 'Puste. Przy zapisie zostanie uzupełnione treścią strony; lepiej napisać własny opis.',
seoDescSameAs: 'Taki sam opis jak na stronie „{{name}}”. Google pomija opis powtarzany na wielu stronach; każdy powinien być inny.',
seoDescSameAsSite: 'Taki sam jak opis witryny. Google pomija opis powtarzany na wielu stronach; napisz opis tej strony.',
statsBack: 'Wróć do statystyk',
statsChartDay: '{{day}} · Wizyty: {{visits}} · Odsłony: {{views}}',
statsChartTable: 'Tabela',
statsColDay: 'Dzień',
statsColDevice: 'Urządzenie',
statsColEntryPage: 'Strona wejścia',
statsColLastVisit: 'Ostatnia wizyta',
statsColPage: 'Strona',
statsColReferrer: 'Strona odsyłająca',
statsColViews: 'Odsłony',
statsColVisitor: 'Odwiedzający',
statsConsentedVisits: 'Wizyty ze zgodą na analitykę',
statsDeviceDesktop: 'Komputer',
statsDeviceMobile: 'Telefon',
statsDeviceTablet: 'Tablet',
statsDirect: '(bezpośrednio)',
statsFrom: 'z {{referrer}}',
statsIntro: 'Ostatnie 30 dni, liczone bez cookies i bez zapisywania adresów IP.',
statsNavLink: 'Przegląd',
statsNoAccess: 'Brak dostępu do statystyk.',
statsNoData: 'Brak danych. Pojawią się po pierwszych wizytach.',
statsNoVisitors: 'Żaden odwiedzający nie zaakceptował jeszcze cookies analitycznych.',
statsPagesFew: '{{count}} strony',
statsPagesMany: '{{count}} stron',
statsPagesOne: '{{count}} strona',
statsPagesOther: '{{count}} strony',
statsPagesPerVisit: 'Strony na wizytę',
statsPageViews: 'Odsłony',
statsSinglePageVisits: 'Wizyty jednostronicowe',
statsTitle: 'Statystyki',
statsUnknownDevice: 'Nieznane urządzenie',
statsVisitorErase: 'Aby usunąć dane tego odwiedzającego, przefiltruj listę wizyt po jego identyfikatorze i usuń wyniki.',
statsVisitorHeading: 'Odwiedzający',
statsVisitorHistory: 'Historia odwiedzających (za zgodą)',
statsVisitorLink: 'Odwiedzający {{id}}',
statsVisitorVisitsFew: '{{count}} wizyty zapisane za zgodą na analitykę.',
statsVisitorVisitsMany: '{{count}} wizyt zapisanych za zgodą na analitykę.',
statsVisitorVisitsOne: '{{count}} wizyta zapisana za zgodą na analitykę.',
statsVisitorVisitsOther: '{{count}} wizyty zapisanej za zgodą na analitykę.',
statsVisits: 'Wizyty',
statsVisitsPerDay: 'Wizyty dziennie',
statsWidgetLink: 'Wszystkie statystyki',
statsWidgetSummary: 'Ostatnie 30 dni · Wizyty: {{visits}} · Odsłony: {{views}}',
},
})
+12
View File
@@ -0,0 +1,12 @@
import { consentTexts } from './consent.js'
import { contentTexts } from './content.js'
import { integrationsTexts } from './integrations.js'
import { settingsTexts } from './settings.js'
/** Every admin component text, by language. Payload reads them as `ipal:<key>`. */
export const adminTexts = {
en: { ...settingsTexts.en, ...integrationsTexts.en, ...consentTexts.en, ...contentTexts.en },
pl: { ...settingsTexts.pl, ...integrationsTexts.pl, ...consentTexts.pl, ...contentTexts.pl },
}
export type AdminTextKey = keyof typeof adminTexts.en
@@ -0,0 +1,104 @@
import { defineTexts } from '../define.js'
/** Admin component texts — integrations. Placeholders use Payload's {{name}} syntax. */
export const integrationsTexts = defineTexts({
en: {
// Dashboard alert (IntegrationAlerts)
alertsHeading: 'An integration needs attention. The site still works.',
alertsLink: 'Go to Site integrations',
alertsUnknownError: 'Unknown error.',
// Masked secret field
maskedHide: 'Hide',
maskedShow: 'Show',
// Status banner on an integration's tab (IntegrationStatusBanner)
statusCode: 'Code: {{code}}.',
statusEmailFailing: 'E-mail sending is not working. Form notifications may not arrive.',
statusEmailHint: 'Correct the settings below, save and send a test e-mail.',
statusFailing: '{{label}} is not working.',
statusHint: 'Correct the settings below and save.',
statusLastChecked: 'Last checked {{date}}.',
statusSince: 'Since {{date}}.',
statusTurnstileFailing: 'Spam protection is not working. Forms are accepted without this check.',
statusTurnstileHint: 'Correct the keys below and save. The status updates after the next form submission.',
statusWorking: '{{label}}: working.',
statusWorkingSince: '{{label}}: working since {{date}}.',
// Status messages, by status code
statusEmailGraphUnavailable:
'Microsoft Graph is selected but not set up on the server, so e-mails go over SMTP. Ask your administrator.',
statusTurnstileBadResponse: 'Cloudflare sent an unexpected response.',
statusTurnstileInternalError: 'Cloudflare reported an internal error. It usually passes on its own.',
statusTurnstileInvalidSecret: 'Cloudflare rejected the secret key. Both keys must come from the same widget.',
statusTurnstileMissingSecret: 'The secret key is missing.',
statusTurnstileNetworkError: 'The server could not reach Cloudflare.',
statusTurnstileNoSecretKey: 'The secret key is missing, so spam protection is off. Fill in both keys or clear both.',
statusTurnstileNoSiteKey: 'The site key is missing, so spam protection is off. Fill in both keys or clear both.',
// Test e-mail (button + endpoint)
testEmailBody: 'This is a test message from {{site}}. If it arrived, e-mail sending works.',
testEmailBodyGeneric: 'This is a test message from your website. If it arrived, e-mail sending works.',
testEmailFailed: 'The test e-mail was not sent. Check the settings above and try again.',
testEmailForbidden: 'Only an administrator can send a test e-mail.',
testEmailHint: 'Save your changes first. The test uses the saved settings.',
testEmailInvalidRecipient: 'Enter a valid e-mail address, e.g. [email protected].',
testEmailLabel: 'Test e-mail',
testEmailLoggedOut: 'Your session has ended. Log in again.',
testEmailNoConnection: 'Could not reach the server. Check your connection and try again.',
testEmailNotConfigured: 'Fill in the server, user name and password, then save.',
testEmailRecipient: 'Recipient address',
testEmailSend: 'Send test e-mail',
testEmailSending: 'Sending…',
testEmailSent: 'Test e-mail sent to {{to}}.',
testEmailSubject: 'Test e-mail from {{site}}',
testEmailSubjectGeneric: 'Test e-mail from your website',
},
pl: {
alertsHeading: 'Integracja wymaga uwagi. Witryna nadal działa.',
alertsLink: 'Przejdź do integracji',
alertsUnknownError: 'Nieznany błąd.',
maskedHide: 'Ukryj',
maskedShow: 'Pokaż',
statusCode: 'Kod: {{code}}.',
statusEmailFailing: 'Wysyłka e-mail nie działa. Powiadomienia z formularzy mogą nie docierać.',
statusEmailHint: 'Popraw ustawienia poniżej, zapisz i wyślij testowy e-mail.',
statusFailing: '{{label}}: nie działa.',
statusHint: 'Popraw ustawienia poniżej i zapisz.',
statusLastChecked: 'Ostatnie sprawdzenie: {{date}}.',
statusSince: 'Od {{date}}.',
statusTurnstileFailing: 'Ochrona przed spamem nie działa. Formularze są przyjmowane bez tej kontroli.',
statusTurnstileHint: 'Popraw klucze poniżej i zapisz. Status odświeży się po następnym zgłoszeniu z formularza.',
statusWorking: '{{label}}: działa.',
statusWorkingSince: '{{label}}: działa od {{date}}.',
statusEmailGraphUnavailable:
'Wybrano Microsoft Graph, ale nie jest on skonfigurowany na serwerze, więc e-maile idą przez SMTP. Zapytaj administratora.',
statusTurnstileBadResponse: 'Cloudflare zwrócił nieoczekiwaną odpowiedź.',
statusTurnstileInternalError: 'Cloudflare zgłosił błąd wewnętrzny. Zwykle ustępuje samoczynnie.',
statusTurnstileInvalidSecret: 'Cloudflare odrzucił klucz tajny. Oba klucze muszą pochodzić z tego samego widżetu.',
statusTurnstileMissingSecret: 'Brak klucza tajnego.',
statusTurnstileNetworkError: 'Serwer nie może połączyć się z Cloudflare.',
statusTurnstileNoSecretKey: 'Brak klucza tajnego, więc ochrona przed spamem jest wyłączona. Uzupełnij oba klucze albo usuń oba.',
statusTurnstileNoSiteKey: 'Brak klucza witryny, więc ochrona przed spamem jest wyłączona. Uzupełnij oba klucze albo usuń oba.',
testEmailBody: 'To jest wiadomość testowa z witryny {{site}}. Jeśli dotarła, wysyłka e-mail działa.',
testEmailBodyGeneric: 'To jest wiadomość testowa z witryny. Jeśli dotarła, wysyłka e-mail działa.',
testEmailFailed: 'Nie wysłano testowego e-maila. Sprawdź ustawienia powyżej i spróbuj ponownie.',
testEmailForbidden: 'Tylko administrator może wysłać testowy e-mail.',
testEmailHint: 'Najpierw zapisz zmiany. Test używa zapisanych ustawień.',
testEmailInvalidRecipient: 'Wpisz poprawny adres e-mail, np. [email protected].',
testEmailLabel: 'Testowy e-mail',
testEmailLoggedOut: 'Sesja wygasła. Zaloguj się ponownie.',
testEmailNoConnection: 'Brak połączenia z serwerem. Sprawdź połączenie i spróbuj ponownie.',
testEmailNotConfigured: 'Uzupełnij serwer, nazwę użytkownika i hasło, a następnie zapisz.',
testEmailRecipient: 'Adres odbiorcy',
testEmailSend: 'Wyślij testowy e-mail',
testEmailSending: 'Wysyłanie…',
testEmailSent: 'Testowy e-mail wysłano na adres {{to}}.',
testEmailSubject: 'Testowy e-mail z witryny {{site}}',
testEmailSubjectGeneric: 'Testowy e-mail z witryny',
},
})
+11
View File
@@ -0,0 +1,11 @@
import { defineTexts } from '../define.js'
/** Admin component texts — settings. Placeholders use Payload's {{name}} syntax. */
export const settingsTexts = defineTexts({
en: {
brandingCredit: 'Technology supported by Intecion.com',
},
pl: {
brandingCredit: 'Technologię wspiera Intecion.com',
},
})