Admin follow-ups: localised stats tab title, scanner names, close label, favicon hint
- Statistics view: the browser-tab title follows the admin language.
Payload's custom-view meta.title is one plain string and its custom-view
metadata ignores i18n, so the view renders <DocumentTitle> (/admin) with the
translated title; it re-applies the title while the view is open because
Next streams the English metadata in after hydration. adminDocumentTitle()
adds admin.meta.titleSuffix the way Payload does.
- Cookie scanner: CookieIntegration.label may be { en, pl, ... }. The built-in
names without a product name come from the shared admin texts
(cookieIntegration*, cookieSourceProject); the scan endpoint answers in the
request's admin language and stored source names use the scanning editor's.
- Maintenance notice: getConstructionMode(locale) returns `locale`; the "x"
close button gets a screen-reader name "Close" / "Zamknij" (locale and
closeLabel props; constructionCloseLabel exported).
- Favicon: FaviconCheck (/admin, afterInput on Site settings -> Site icon)
warns in the admin language when the image is under 48x48 or not square,
without blocking the save; validateFaviconField shares faviconProblems().
- Docs, AGENT.md and skills: the above, plus Next.js 16.4.1 or later as the
minimum safe version (AGENT.md 4.11, ipal-setup, ipal-upgrade).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6f32ea4cdb
commit
546806fe39
@@ -0,0 +1,27 @@
|
||||
'use client'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
/**
|
||||
* Sets the browser-tab title of a custom admin view in the admin language.
|
||||
*
|
||||
* Payload takes a custom view's `meta.title` as one plain string and does not
|
||||
* translate it, so the server-rendered title stays in English. The view
|
||||
* renders this with its translated title (server side, from `req.i18n`) and
|
||||
* the tab follows the editor's language once the page has loaded.
|
||||
*
|
||||
* On a full page load Next streams the view's metadata in after hydration and
|
||||
* writes the English title back, so the title is re-applied whenever the head
|
||||
* changes while the view is open.
|
||||
*/
|
||||
export function DocumentTitle({ title }: { title: string }) {
|
||||
useEffect(() => {
|
||||
const apply = () => {
|
||||
if (document.title !== title) {document.title = title}
|
||||
}
|
||||
apply()
|
||||
const observer = new MutationObserver(apply)
|
||||
observer.observe(document.head, { characterData: true, childList: true, subtree: true })
|
||||
return () => observer.disconnect()
|
||||
}, [title])
|
||||
return null
|
||||
}
|
||||
@@ -1,6 +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 { adminDocumentTitle, formatDateTime, formatNumber, ipalT } from './t.js'
|
||||
export { adminTexts } from './texts/index.js'
|
||||
export type { AdminTextKey } from './texts/index.js'
|
||||
|
||||
@@ -17,3 +17,6 @@ export const formatNumber = (n: number, language: string) => new Intl.NumberForm
|
||||
/** 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))
|
||||
|
||||
/** The tab title Payload builds for a view: its title plus `admin.meta.titleSuffix`. */
|
||||
export const adminDocumentTitle = (title: string, titleSuffix?: null | string) => (titleSuffix ? `${title} ${titleSuffix}` : title)
|
||||
|
||||
@@ -2,6 +2,18 @@ import { defineTexts } from '../define.js'
|
||||
|
||||
/** Admin component texts — consent. Placeholders use Payload's {{name}} syntax. */
|
||||
export const consentTexts = defineTexts({
|
||||
en: {},
|
||||
pl: {},
|
||||
en: {
|
||||
cookieIntegrationAdmin: 'Admin panel login',
|
||||
cookieIntegrationConsent: 'Cookie banner',
|
||||
cookieIntegrationLocale: 'Language choice',
|
||||
cookieIntegrationStats: 'Built-in statistics',
|
||||
cookieSourceProject: 'Project',
|
||||
},
|
||||
pl: {
|
||||
cookieIntegrationAdmin: 'Logowanie do panelu',
|
||||
cookieIntegrationConsent: 'Baner cookies',
|
||||
cookieIntegrationLocale: 'Wybór języka',
|
||||
cookieIntegrationStats: 'Wbudowane statystyki',
|
||||
cookieSourceProject: 'Projekt',
|
||||
},
|
||||
})
|
||||
|
||||
@@ -4,8 +4,12 @@ import { defineTexts } from '../define.js'
|
||||
export const settingsTexts = defineTexts({
|
||||
en: {
|
||||
brandingCredit: 'Technology supported by Intecion.com',
|
||||
faviconNotSquare: 'The icon is not square ({{width}}×{{height}} px), so it may be cropped in tabs and search results.',
|
||||
faviconTooSmall: 'The icon is {{width}}×{{height}} px. Google shows icons of at least 48×48 px; upload a larger one.',
|
||||
},
|
||||
pl: {
|
||||
brandingCredit: 'Technologię wspiera Intecion.com',
|
||||
faviconNotSquare: 'Ikona nie jest kwadratowa ({{width}}×{{height}} px), więc może być przycięta na kartach i w wynikach wyszukiwania.',
|
||||
faviconTooSmall: 'Ikona ma {{width}}×{{height}} px. Google pokazuje ikony od 48×48 px; wgraj większą.',
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user