UNPKG

@hyperse/translator

Version:

Translates messages from the given namespace by using the ICU syntax.

1 lines 51.9 kB
{"version":3,"sources":["../src/utils/joinPath.ts","../src/defaults.ts","../src/IntlError.ts","../src/utils/convertFormatsToIntlMessageFormat.ts","../src/formatter/formatters.ts","../src/utils/createMessageFormatter.ts","../src/utils/resolvePath.ts","../src/utils/getMessagesOrError.ts","../src/utils/getPlainMessage.ts","../src/utils/prepareTranslationValues.ts","../src/createBaseTranslator.ts","../src/utils/resolveNamespace.ts","../src/createTranslatorImpl.ts","../src/createTranslator.ts","../src/formatter/createFormatter.ts"],"names":["IntlMessageFormat","isValidElement"],"mappings":";;;;;;;AAAO,SAAS,YAAY,KAAkC,EAAA;AAC5D,EAAA,OAAO,KAAM,CAAA,MAAA,CAAO,OAAO,CAAA,CAAE,KAAK,GAAG,CAAA;AACvC;;;ACMO,SAAS,0BAA0B,KAIvC,EAAA;AACD,EAAA,OAAO,QAAS,CAAA,KAAA,CAAM,SAAW,EAAA,KAAA,CAAM,GAAG,CAAA;AAC5C;AAEO,SAAS,eAAe,KAAkB,EAAA;AAC/C,EAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AACrB;;;ACRO,IAAM,SAAA,GAAN,cAAwB,KAAM,CAAA;AAAA,EAInC,WAAA,CAAY,MAAqB,eAA0B,EAAA;AACzD,IAAA,IAAI,OAAkB,GAAA,IAAA;AACtB,IAAA,IAAI,eAAiB,EAAA;AACnB,MAAA,OAAA,IAAW,IAAO,GAAA,eAAA;AAAA;AAEpB,IAAA,KAAA,CAAM,OAAO,CAAA;AAEb,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA;AACZ,IAAA,IAAI,eAAiB,EAAA;AACnB,MAAA,IAAA,CAAK,eAAkB,GAAA,eAAA;AAAA;AACzB;AAEJ,CAAA;ACpBA,SAAS,oBAAA,CACP,SACA,QACA,EAAA;AACA,EAAI,IAAA,CAAC,SAAgB,OAAA,OAAA;AAIrB,EAAO,OAAA,MAAA,CAAO,IAAK,CA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AAiB,OAAO,KAAK,CAAA;AAC7B,QAAW,UAAA,CAAA,GAAA,CAAI,gBAAgB,IAAI,CAAA;AAAA,OAC9B,MAAA;AACL,QAAA,cAAA,GAAiB,OAAO,IAAI,CAAA;AAAA;AAE9B,MAAA,eAAA,CAAgB,KAAK,cAAc,CAAA;AACnC,MAAA,KAAA,EAAA;AAAA;AAGF,IAAO,OAAA,iBAAA;AAAA,MAIL,eAAA;AAAA,MACA,OAAS,IAAA,IAAA,GAAA,MAAA,GAAA,OAAA,CAAA,IAAA;AAAA;AAAA,MAET,CAAC,OAAY,KAAA;AACX,QAAM,MAAA,MAAA,GAAS,WACZ,aAAc,CAAA,MAAA,EAAQ,OAAO,CAC7B,CAAA,aAAA,CAAc,eAAe,CAC7B,CAAA,GAAA;AAAA,UAAI,CAAC,IAAA,KACJ,IAAK,CAAA,IAAA,KAAS,SACV,GAAA,IAAA,CAAK,KACL,GAAA,UAAA,CAAW,GAAI,CAAA,IAAA,CAAK,KAAK,CAAA,IAAK,IAAK,CAAA;AAAA,SACzC;AAEF,QAAI,IAAA,UAAA,CAAW,OAAO,CAAG,EAAA;AACvB,UAAO,OAAA,MAAA;AAAA,SACF,MAAA;AACL,UAAO,OAAA,MAAA,CAAO,KAAK,EAAE,CAAA;AAAA;AACvB,OACF;AAAA,MACA,MAAM,OAAO,KAAK;AAAA,KACpB;AAAA;AAGF,EAAA,OAAO,EAAE,QAAA,EAAU,MAAQ,EAAA,YAAA,EAAc,MAAM,aAAc,EAAA;AAC/D","file":"index.mjs","sourcesContent":["export function joinPath(...parts: Array<string | undefined>) {\n return parts.filter(Boolean).join('.');\n}\n","import type { IntlError } from './IntlError.js';\nimport { joinPath } from './utils/joinPath.js';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return joinPath(props.namespace, props.key);\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n","export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n ENVIRONMENT_FALLBACK = 'ENVIRONMENT_FALLBACK',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR',\n}\n\nexport class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n","import type { Formats as IntlFormats } from 'intl-messageformat';\nimport { IntlMessageFormat } from 'intl-messageformat';\nimport type { DateTimeFormatOptions } from '../types/DateTimeFormatOptions.js';\nimport type { Formats } from '../types/Formats.js';\nimport type { TimeZone } from '../types/TimeZone.js';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: TimeZone\n) {\n if (!formats) return formats;\n\n // The only way to set a time zone with `intl-messageformat` is to merge it into the formats\n // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15\n return Object.keys(formats).reduce(\n (acc: Record<string, DateTimeFormatOptions>, key) => {\n acc[key] = {\n timeZone,\n ...formats[key],\n };\n return acc;\n },\n {}\n );\n}\n\n/**\n * `intl-messageformat` uses separate keys for `date` and `time`, but there's\n * only one native API: `Intl.DateTimeFormat`. Additionally you might want to\n * include both a time and a date in a value, therefore the separation doesn't\n * seem so useful. We offer a single `dateTime` namespace instead, but we have\n * to convert the format before `intl-messageformat` can be used.\n */\nexport function convertFormatsToIntlMessageFormat(\n formats: Partial<Formats>,\n timeZone?: TimeZone\n): Partial<IntlFormats> {\n const formatsWithTimeZone = timeZone\n ? { ...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone) }\n : formats;\n\n const mfDateDefaults = IntlMessageFormat.formats.date as Formats['dateTime'];\n const defaultDateFormats = timeZone\n ? setTimeZoneInFormats(mfDateDefaults, timeZone)\n : mfDateDefaults;\n\n const mfTimeDefaults = IntlMessageFormat.formats.time as Formats['dateTime'];\n const defaultTimeFormats = timeZone\n ? setTimeZoneInFormats(mfTimeDefaults, timeZone)\n : mfTimeDefaults;\n\n return {\n ...formatsWithTimeZone,\n date: {\n ...defaultDateFormats,\n ...formatsWithTimeZone?.dateTime,\n },\n time: {\n ...defaultTimeFormats,\n ...formatsWithTimeZone?.dateTime,\n },\n };\n}\n","import type { IntlMessageFormat } from 'intl-messageformat';\nimport type { Cache } from '@formatjs/fast-memoize';\nimport { memoize, strategies } from '@formatjs/fast-memoize';\n\nexport type IntlCache = {\n dateTime: Record<string, Intl.DateTimeFormat>;\n number: Record<string, Intl.NumberFormat>;\n message: Record<string, IntlMessageFormat>;\n relativeTime: Record<string, Intl.RelativeTimeFormat>;\n pluralRules: Record<string, Intl.PluralRules>;\n list: Record<string, Intl.ListFormat>;\n displayNames: Record<string, Intl.DisplayNames>;\n};\n\nexport function createCache(): IntlCache {\n return {\n dateTime: {},\n number: {},\n message: {},\n relativeTime: {},\n pluralRules: {},\n list: {},\n displayNames: {},\n };\n}\n\nfunction createMemoCache<Value>(\n store: Record<string, Value | undefined>\n): Cache<string, Value> {\n return {\n create() {\n return {\n get(key) {\n return store[key];\n },\n set(key, value) {\n store[key] = value;\n },\n };\n },\n };\n}\n\nexport function memoFn<Fn extends (...args: Array<any>) => any>(\n fn: Fn,\n cache: Record<string, ReturnType<Fn> | undefined>\n) {\n return memoize(fn, {\n cache: createMemoCache(cache),\n strategy: strategies.variadic,\n }) as Fn;\n}\n\nfunction memoConstructor<Fn extends new (...args: Array<any>) => unknown>(\n ConstructorFn: Fn,\n cache: Record<string, InstanceType<Fn> | undefined>\n) {\n return memoFn(\n (...args: ConstructorParameters<Fn>) => new ConstructorFn(...args),\n cache\n ) as (...args: ConstructorParameters<Fn>) => InstanceType<Fn>;\n}\n\nexport type IntlFormatters = {\n getDateTimeFormat(\n ...args: ConstructorParameters<typeof Intl.DateTimeFormat>\n ): Intl.DateTimeFormat;\n getNumberFormat(\n ...args: ConstructorParameters<typeof Intl.NumberFormat>\n ): Intl.NumberFormat;\n getPluralRules(\n ...args: ConstructorParameters<typeof Intl.PluralRules>\n ): Intl.PluralRules;\n getRelativeTimeFormat(\n ...args: ConstructorParameters<typeof Intl.RelativeTimeFormat>\n ): Intl.RelativeTimeFormat;\n getListFormat(\n ...args: ConstructorParameters<typeof Intl.ListFormat>\n ): Intl.ListFormat;\n getDisplayNames(\n ...args: ConstructorParameters<typeof Intl.DisplayNames>\n ): Intl.DisplayNames;\n};\n\nexport function createIntlFormatters(cache: IntlCache): IntlFormatters {\n const getDateTimeFormat = memoConstructor(\n Intl.DateTimeFormat,\n cache.dateTime\n );\n const getNumberFormat = memoConstructor(Intl.NumberFormat, cache.number);\n const getPluralRules = memoConstructor(Intl.PluralRules, cache.pluralRules);\n const getRelativeTimeFormat = memoConstructor(\n Intl.RelativeTimeFormat,\n cache.relativeTime\n );\n const getListFormat = memoConstructor(Intl.ListFormat, cache.list);\n const getDisplayNames = memoConstructor(\n Intl.DisplayNames,\n cache.displayNames\n );\n\n return {\n getDateTimeFormat,\n getNumberFormat,\n getPluralRules,\n getRelativeTimeFormat,\n getListFormat,\n getDisplayNames,\n };\n}\n\nexport type MessageFormatter = (\n ...args: ConstructorParameters<typeof IntlMessageFormat>\n) => IntlMessageFormat;\n\nexport type Formatters = IntlFormatters & {\n getMessageFormat?: MessageFormatter;\n};\n","// Placed here for improved tree shaking. Somehow when this is placed in\nimport { IntlMessageFormat } from 'intl-messageformat';\nimport type {\n IntlCache,\n IntlFormatters,\n MessageFormatter,\n} from '../formatter/formatters.js';\nimport { memoFn } from '../formatter/formatters.js';\n\n// `formatters.tsx`, then it can't be shaken off from `next-intl`.\nexport function createMessageFormatter(\n cache: IntlCache,\n intlFormatters: IntlFormatters\n): MessageFormatter {\n const getMessageFormat = memoFn(\n (...args: ConstructorParameters<typeof IntlMessageFormat>) =>\n new IntlMessageFormat(args[0], args[1], args[2], {\n formatters: intlFormatters,\n ...args[3],\n }),\n cache.message\n );\n\n return getMessageFormat;\n}\n","import type { AbstractIntlMessages } from '../types/AbstractIntlMessages.js';\nimport { joinPath } from './joinPath.js';\n\nexport function resolvePath(\n locale: string,\n messages: AbstractIntlMessages | undefined,\n key: string,\n namespace?: string\n): AbstractIntlMessages {\n const fullKey = joinPath(namespace, key);\n\n if (!messages) {\n throw new Error(`No messages available at \\`${namespace}\\`.`);\n }\n\n let message: AbstractIntlMessages | string = messages;\n\n key.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n `Could not resolve \\`${fullKey}\\` in messages for locale \\`${locale}\\`.`\n );\n }\n\n message = next;\n });\n\n return message;\n}\n","import { defaultOnError } from '../defaults.js';\nimport { IntlError, IntlErrorCode } from '../IntlError.js';\nimport type { AbstractIntlMessages } from '../types/AbstractIntlMessages.js';\nimport { resolvePath } from './resolvePath.js';\n\nexport function getMessagesOrError<Messages extends AbstractIntlMessages>(\n locale: string,\n messages?: Messages,\n namespace?: string,\n onError: (error: IntlError) => void = defaultOnError\n) {\n try {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages were configured on the provider.`\n : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(locale, messages, namespace)\n : messages;\n\n if (!retrievedMessages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages for namespace \\`${namespace}\\` found.`\n : namespace\n );\n }\n\n return retrievedMessages;\n } catch (error) {\n const intlError = new IntlError(\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n onError(intlError);\n return intlError;\n }\n}\n","export function getPlainMessage(candidate: string, values?: unknown) {\n if (values) return undefined;\n\n const unescapedMessage = candidate.replace(/'([{}])/gi, '$1');\n\n // Placeholders can be in the message if there are default values,\n // or if the user has forgotten to provide values. In the latter\n // case we need to compile the message to receive an error.\n const hasPlaceholders = /<|{/.test(unescapedMessage);\n\n if (!hasPlaceholders) {\n return unescapedMessage;\n }\n\n return undefined;\n}\n","import type { ReactNode } from 'react';\nimport { cloneElement, isValidElement } from 'react';\nimport type { RichTranslationValues } from '../types/TranslationValues.js';\n\nexport function prepareTranslationValues(values: RichTranslationValues) {\n if (Object.keys(values).length === 0) return undefined;\n\n // Workaround for https://github.com/formatjs/formatjs/issues/1467\n const transformedValues: RichTranslationValues = {};\n Object.keys(values).forEach((key) => {\n let index = 0;\n const value = values[key];\n\n let transformed;\n if (typeof value === 'function') {\n transformed = (chunks: ReactNode) => {\n const result = value(chunks);\n\n return isValidElement(result)\n ? cloneElement(result, { key: key + index++ })\n : result;\n };\n } else {\n transformed = value;\n }\n\n transformedValues[key] = transformed;\n });\n\n return transformedValues;\n}\n","import type { ReactElement, ReactNode } from 'react';\nimport { isValidElement } from 'react';\nimport type { Formats } from 'intl-messageformat';\nimport type { IntlMessageFormat } from 'intl-messageformat';\nimport { defaultGetMessageFallback } from './defaults.js';\nimport type { Formatters, IntlCache } from './formatter/formatters.js';\nimport { IntlError, IntlErrorCode } from './IntlError.js';\nimport type { AbstractIntlMessages } from './types/AbstractIntlMessages.js';\nimport type { InitializedIntlConfig } from './types/IntlConfig.js';\nimport type { MessageKeys } from './types/MessageKeys.js';\nimport type { NestedKeyOf } from './types/NestedKeyOf.js';\nimport type { NestedValueOf } from './types/NestedValueOf.js';\nimport type { RichTranslationValues } from './types/TranslationValues.js';\nimport { convertFormatsToIntlMessageFormat } from './utils/convertFormatsToIntlMessageFormat.js';\nimport { createMessageFormatter } from './utils/createMessageFormatter.js';\nimport { getMessagesOrError } from './utils/getMessagesOrError.js';\nimport { getPlainMessage } from './utils/getPlainMessage.js';\nimport { joinPath } from './utils/joinPath.js';\nimport { prepareTranslationValues } from './utils/prepareTranslationValues.js';\nimport { resolvePath } from './utils/resolvePath.js';\n\nexport type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {\n cache: IntlCache;\n formatters: Formatters;\n defaultTranslationValues?: RichTranslationValues;\n namespace?: string;\n messagesOrError: Messages | IntlError;\n};\n\nexport function createBaseTranslator<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>,\n>(config: Omit<CreateBaseTranslatorProps<Messages>, 'messagesOrError'>) {\n const messagesOrError = getMessagesOrError(\n config.locale,\n config.messages,\n config.namespace,\n config.onError\n ) as Messages | IntlError;\n return createBaseTranslatorImpl<Messages, NestedKey>({\n ...config,\n messagesOrError,\n });\n}\n\nexport function createBaseTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>,\n>({\n cache,\n defaultTranslationValues,\n formats: globalFormats,\n formatters,\n getMessageFallback = defaultGetMessageFallback,\n locale,\n messagesOrError,\n namespace,\n onError,\n timeZone,\n}: CreateBaseTranslatorProps<Messages>) {\n function getFallbackFromErrorAndNotify(\n key: string,\n code: IntlErrorCode,\n message?: string\n ) {\n const error = new IntlError(code, message);\n onError(error);\n return getMessageFallback({ error, key, namespace });\n }\n\n function translateBaseFn(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string,\n /** Key value pairs for values to interpolate into the message. */\n values?: RichTranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNode[] {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace,\n });\n }\n\n const messages = messagesOrError;\n\n let message;\n try {\n message = resolvePath(locale, messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n\n if (typeof message === 'object') {\n let code, errorMessage;\n if (Array.isArray(message)) {\n code = IntlErrorCode.INVALID_MESSAGE;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath(\n namespace,\n key\n )}\\` resolved to an array, but only strings are supported.`;\n }\n } else {\n code = IntlErrorCode.INSUFFICIENT_PATH;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath(\n namespace,\n key\n )}\\` resolved to an object, but only strings are supported. Use a \\`.\\` to retrieve nested messages.`;\n }\n }\n\n return getFallbackFromErrorAndNotify(key, code, errorMessage);\n }\n\n let messageFormat: IntlMessageFormat;\n\n // Hot path that avoids creating an `IntlMessageFormat` instance\n const plainMessage = getPlainMessage(message as string, values);\n if (plainMessage) return plainMessage;\n\n // Lazy init the message formatter for better tree\n // shaking in case message formatting is not used.\n if (!formatters.getMessageFormat) {\n formatters.getMessageFormat = createMessageFormatter(cache, formatters);\n }\n\n try {\n messageFormat = formatters.getMessageFormat(\n message,\n locale,\n convertFormatsToIntlMessageFormat(\n { ...globalFormats, ...formats },\n timeZone\n ),\n {\n formatters: {\n ...formatters,\n getDateTimeFormat(locales, options) {\n // Workaround for https://github.com/formatjs/formatjs/issues/4279\n return formatters.getDateTimeFormat(locales, {\n timeZone,\n ...options,\n });\n },\n },\n }\n );\n } catch (error) {\n const thrownError = error as Error;\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n process.env.NODE_ENV !== 'production'\n ? thrownError.message +\n ('originalMessage' in thrownError\n ? ` (${thrownError.originalMessage})`\n : '')\n : thrownError.message\n );\n }\n\n try {\n const formattedMessage = messageFormat.format(\n // @ts-expect-error `intl-messageformat` expects a different format\n // for rich text elements since a recent minor update. This\n // needs to be evaluated in detail, possibly also in regards\n // to be able to format to parts.\n prepareTranslationValues({ ...defaultTranslationValues, ...values })\n );\n\n if (formattedMessage == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Unable to format \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n }`\n : undefined\n );\n }\n\n // Limit the function signature to return strings or React elements\n return isValidElement(formattedMessage) ||\n // Arrays of React elements\n Array.isArray(formattedMessage) ||\n typeof formattedMessage === 'string'\n ? formattedMessage\n : String(formattedMessage);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.FORMATTING_ERROR,\n (error as Error).message\n );\n }\n }\n\n function translateFn<\n TargetKey extends MessageKeys<\n NestedValueOf<Messages, NestedKey>,\n NestedKeyOf<NestedValueOf<Messages, NestedKey>>\n >,\n >(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: TargetKey,\n /** Key value pairs for values to interpolate into the message. */\n values?: RichTranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string {\n const result = translateBaseFn(key, values, formats);\n\n if (typeof result !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n `The message \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n } didn't resolve to a string.`\n );\n }\n\n return result;\n }\n translateFn.rich = translateBaseFn;\n\n return translateFn;\n}\n","export function resolveNamespace(namespace: string, namespacePrefix: string) {\n return namespace === namespacePrefix\n ? undefined\n : namespace.slice((namespacePrefix + '.').length);\n}\n","import { createBaseTranslator } from './createBaseTranslator.js';\nimport type { Formatters, IntlCache } from './formatter/formatters.js';\nimport type { AbstractIntlMessages } from './types/AbstractIntlMessages.js';\nimport type { InitializedIntlConfig } from './types/IntlConfig.js';\nimport type { NestedKeyOf } from './types/NestedKeyOf.js';\nimport { resolveNamespace } from './utils/resolveNamespace.js';\n\nexport type CreateTranslatorImplProps<Messages> = Omit<\n InitializedIntlConfig,\n 'messages'\n> & {\n namespace: string;\n messages: Messages;\n formatters: Formatters;\n cache: IntlCache;\n};\n\nexport function createTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>,\n>(\n { messages, namespace, ...rest }: CreateTranslatorImplProps<Messages>,\n namespacePrefix: string\n) {\n // The `namespacePrefix` is part of the type system.\n // See the comment in the function invocation.\n messages = messages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n const translator = createBaseTranslator<Messages, NestedKey>({\n ...rest,\n namespace,\n messages,\n });\n\n function base(...args: Parameters<typeof translator>) {\n return translator(...args);\n }\n base.rich = function (...args: Parameters<typeof translator>) {\n return translator.rich(...args);\n };\n return base;\n}\n","import type { ReactElement, ReactNode } from 'react';\nimport type { Formats } from 'intl-messageformat';\nimport { createTranslatorImpl } from './createTranslatorImpl.js';\nimport { defaultGetMessageFallback, defaultOnError } from './defaults.js';\nimport type { Formatters, IntlCache } from './formatter/formatters.js';\nimport { createCache, createIntlFormatters } from './formatter/formatters.js';\nimport type { AbstractIntlMessages } from './types/AbstractIntlMessages.js';\nimport type { IntlConfig } from './types/IntlConfig.js';\nimport type { MessageKeys } from './types/MessageKeys.js';\nimport type { NamespaceKeys } from './types/NamespaceKeys.js';\nimport type { NestedKeyOf } from './types/NestedKeyOf.js';\nimport type { NestedValueOf } from './types/NestedValueOf.js';\nimport type { RichTranslationValues } from './types/TranslationValues.js';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport function createTranslator<\n IntlMessages extends AbstractIntlMessages,\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never,\n>({\n _cache = createCache(),\n _formatters = createIntlFormatters(_cache),\n messages,\n namespace,\n onError = defaultOnError,\n getMessageFallback = defaultGetMessageFallback,\n ...rest\n}: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {\n messages: IntlMessages;\n namespace?: NestedKey;\n /** @private */\n _formatters?: Formatters;\n /** @private */\n _cache?: IntlCache;\n}): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n { '!': IntlMessages },\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n { '!': IntlMessages },\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >,\n >(\n key: TargetKey,\n values?: RichTranslationValues,\n formats?: Partial<Formats>\n ): string;\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n { '!': IntlMessages },\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n { '!': IntlMessages },\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >,\n >(\n key: TargetKey,\n values?: RichTranslationValues,\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNode[];\n} {\n // We have to wrap the actual function so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return createTranslatorImpl<\n { '!': IntlMessages },\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {\n ...rest,\n cache: _cache,\n formatters: _formatters,\n onError,\n getMessageFallback,\n messages: { '!': messages },\n namespace: namespace ? `!.${namespace}` : '!',\n },\n '!'\n );\n}\n","import type { ReactElement } from 'react';\nimport { defaultOnError } from '../defaults.js';\nimport { IntlError, IntlErrorCode } from '../IntlError.js';\nimport type { DateTimeFormatOptions } from '../types/DateTimeFormatOptions.js';\nimport type { Formats } from '../types/Formats.js';\nimport type { NumberFormatOptions } from '../types/NumberFormatOptions.js';\nimport type { RelativeTimeFormatOptions } from '../types/RelativeTimeFormatOptions.js';\nimport type { TimeZone } from '../types/TimeZone.js';\nimport type { Formatters, IntlCache } from './formatters.js';\nimport { createCache, createIntlFormatters } from './formatters.js';\n\nconst SECOND = 1;\nconst MINUTE = SECOND * 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst QUARTER = MONTH * 3;\nconst YEAR = DAY * 365;\n\nconst UNIT_SECONDS: Record<Intl.RelativeTimeFormatUnit, number> = {\n second: SECOND,\n seconds: SECOND,\n minute: MINUTE,\n minutes: MINUTE,\n hour: HOUR,\n hours: HOUR,\n day: DAY,\n days: DAY,\n week: WEEK,\n weeks: WEEK,\n month: MONTH,\n months: MONTH,\n quarter: QUARTER,\n quarters: QUARTER,\n year: YEAR,\n years: YEAR,\n} as const;\n\nfunction resolveRelativeTimeUnit(seconds: number) {\n const absValue = Math.abs(seconds);\n\n if (absValue < MINUTE) {\n return 'second';\n } else if (absValue < HOUR) {\n return 'minute';\n } else if (absValue < DAY) {\n return 'hour';\n } else if (absValue < WEEK) {\n return 'day';\n } else if (absValue < MONTH) {\n return 'week';\n } else if (absValue < YEAR) {\n return 'month';\n }\n return 'year';\n}\n\nfunction calculateRelativeTimeValue(\n seconds: number,\n unit: Intl.RelativeTimeFormatUnit\n) {\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n return Math.round(seconds / UNIT_SECONDS[unit]);\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n /** @private */\n _formatters?: Formatters;\n /** @private */\n _cache?: IntlCache;\n};\n\nexport function createFormatter({\n _cache: cache = createCache(),\n _formatters: formatters = createIntlFormatters(cache),\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone: globalTimeZone,\n}: Props) {\n function applyTimeZone(options?: DateTimeFormatOptions) {\n if (!options?.timeZone) {\n if (globalTimeZone) {\n options = { ...options, timeZone: globalTimeZone };\n } else {\n onError(\n new IntlError(\n IntlErrorCode.ENVIRONMENT_FALLBACK,\n process.env.NODE_ENV !== 'production'\n ? `The \\`timeZone\\` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl-docs.vercel.app/docs/configuration#time-zone`\n : undefined\n )\n );\n }\n }\n\n return options;\n }\n\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Options, Output>(\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => Output,\n getFallback: () => Output\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch {\n return getFallback();\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return getFallback();\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n options = applyTimeZone(options);\n return formatters.getDateTimeFormat(locale, options).format(value);\n },\n () => String(value)\n );\n }\n\n function dateTimeRange(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n start: Date | number,\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n end: Date | number,\n /** If a time zone is supplied, the values are converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n options = applyTimeZone(options);\n return formatters\n .getDateTimeFormat(locale, options)\n .formatRange(start, end);\n },\n () => [dateTime(start), dateTime(end)].join(' – ')\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n formatOrOptions,\n formats?.number,\n (options) => formatters.getNumberFormat(locale, options).format(value),\n () => String(value)\n );\n }\n\n function getGlobalNow() {\n if (globalNow) {\n return globalNow;\n } else {\n onError(\n new IntlError(\n IntlErrorCode.ENVIRONMENT_FALLBACK,\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl-docs.vercel.app/docs/configuration#now`\n : undefined\n )\n );\n return new Date();\n }\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n nowOrOptions?: RelativeTimeFormatOptions['now'] | RelativeTimeFormatOptions\n ) {\n try {\n let nowDate: Date | undefined,\n unit: Intl.RelativeTimeFormatUnit | undefined;\n const opts: Intl.RelativeTimeFormatOptions = {};\n if (nowOrOptions instanceof Date || typeof nowOrOptions === 'number') {\n nowDate = new Date(nowOrOptions);\n } else if (nowOrOptions) {\n if (nowOrOptions.now != null) {\n nowDate = new Date(nowOrOptions.now);\n } else {\n nowDate = getGlobalNow();\n }\n unit = nowOrOptions.unit;\n opts.style = nowOrOptions.style;\n // @ts-expect-error -- Types are slightly outdated\n opts.numberingSystem = nowOrOptions.numberingSystem;\n }\n\n if (!nowDate) {\n nowDate = getGlobalNow();\n }\n\n const dateDate = new Date(date);\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n\n if (!unit) {\n unit = resolveRelativeTimeUnit(seconds);\n }\n\n // `numeric: 'auto'` can theoretically produce output like \"yesterday\",\n // but it only works with integers. E.g. -1 day will produce \"yesterday\",\n // but -1.1 days will produce \"-1.1 days\". Rounding before formatting is\n // not desired, as the given dates might cross a threshold were the\n // output isn't correct anymore. Example: 2024-01-08T23:00:00.000Z and\n // 2024-01-08T01:00:00.000Z would produce \"yesterday\", which is not the\n // case. By using `always` we can ensure correct output. The only exception\n // is the formatting of times <1 second as \"now\".\n opts.numeric = unit === 'second' ? 'auto' : 'always';\n\n const value = calculateRelativeTimeValue(seconds, unit);\n return formatters.getRelativeTimeFormat(locale, opts).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTIN