INNER CODE UNIT · TypeScript

interpolate

arc53/DocsGPT · extensions/react-widget/src/locale/index.ts:133

export const interpolate = (template: string, values?: MessageValues) =>
  values
    ? template.replace(/\{(\w+)\}/g, (match, name: string) =>
        Object.prototype.hasOwnProperty.call(values, name)
          ? String(values[name])
          : match,
      )
    : template;

/** The plural form of `key` for `count` in `locale`, falling back to `_other`. */
export const pluralMessage = (
  messages: Messages,
  locale: SupportedLocale,
  key: PluralKey,
  count: number,
): string => {
  const table = messages as Record<string, string | undefined>;
  let category = 'other';

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…