// Copyright 2024 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import type { IntlShape } from 'react-intl'; import React from 'react'; import type { LocaleMessagesType } from '../types/I18N'; import type { LocalizerType } from '../types/Util'; import { Emojify } from '../components/conversation/Emojify'; import { createCachedIntl as createCachedIntlMain, setupI18n as setupI18nMain, } from './setupI18nMain'; import type { SetupI18nOptionsType } from './setupI18nMain'; import { strictAssert } from './assert'; export { isLocaleMessageType } from './setupI18nMain'; export function renderEmojify(parts: ReadonlyArray): JSX.Element { strictAssert(parts.length === 1, ' must contain only one child'); const text = parts[0]; strictAssert(typeof text === 'string', ' must contain only text'); return ; } export function createCachedIntl( locale: string, icuMessages: Record ): IntlShape { return createCachedIntlMain(locale, icuMessages, { renderEmojify }); } export function setupI18n( locale: string, messages: LocaleMessagesType, options: Omit = {} ): LocalizerType { return setupI18nMain(locale, messages, { ...options, renderEmojify }); }