import type { h } from 'preact' // We're using a generic because languages have different plural rules. export interface Locale { strings: Record> pluralize: (n: number) => T } export type OptionalPluralizeLocale = | (Omit, 'pluralize'> & Partial, 'pluralize'>>) | undefined export type LocaleStrings> = { strings: Partial } // eslint-disable-next-line no-use-before-define export type I18n = Translator['translate'] type Options = { smart_count?: number } & { [key: string]: string | number | h.JSX.Element } function insertReplacement( source: Array, rx: RegExp, replacement: string, ): Array { const newParts: Array = [] source.forEach((chunk) => { // When the source contains multiple placeholders for interpolation, // we should ignore chunks that are not strings, because those // can be JSX objects and will be otherwise incorrectly turned into strings. // Without this condition we’d get this: [object Object] hello [object Object] my