/** * Visitor-facing texts the library blocks render themselves (everything else comes from the panel). * English and Polish ship; another language, or other words: createBlockRegistry({ texts }). */ export type BlockTexts = { /** Screen-reader text for a star rating. {value} = the rating. */ rating: string /** Screen-reader text after a step number. {value} = the number. */ step: string } export const BLOCK_TEXTS: Record<'en' | 'pl', BlockTexts> = { en: { rating: 'Rated {value} out of 5', step: 'Step {value}' }, pl: { rating: 'Ocena: {value} na 5', step: 'Krok {value}' }, } /** The texts for a page locale: the project's own first, then Polish for `pl…`, else English. */ export function blockTexts(locale: string, own?: Partial>>): BlockTexts { const base = locale.toLowerCase().startsWith('pl') ? BLOCK_TEXTS.pl : BLOCK_TEXTS.en return { ...base, ...own?.[locale] } } export const fillText = (text: string, value: number | string) => text.replace('{value}', String(value))