Comparing version 4.0.0-beta-7b755e9 to 4.0.0-beta-7e7011d
@@ -1,3 +0,3 @@ | ||
import { r as resolveNamespace, e as createBaseTranslator, d as createCache, b as createIntlFormatters, f as defaultGetMessageFallback, g as defaultOnError } from './initializeConfig-fLcuxncj.js'; | ||
export { I as IntlError, a as IntlErrorCode, c as createFormatter, i as initializeConfig } from './initializeConfig-fLcuxncj.js'; | ||
import { r as resolveNamespace, e as createBaseTranslator, d as createCache, b as createIntlFormatters, f as defaultGetMessageFallback, g as defaultOnError } from './initializeConfig-DNjOIggo.js'; | ||
export { I as IntlError, a as IntlErrorCode, c as createFormatter, i as initializeConfig } from './initializeConfig-DNjOIggo.js'; | ||
@@ -4,0 +4,0 @@ |
@@ -1,2 +0,2 @@ | ||
export { I as IntlError, a as IntlErrorCode, d as _createCache, b as _createIntlFormatters, c as createFormatter, i as initializeConfig } from './initializeConfig-fLcuxncj.js'; | ||
export { I as IntlError, a as IntlErrorCode, d as _createCache, b as _createIntlFormatters, c as createFormatter, i as initializeConfig } from './initializeConfig-DNjOIggo.js'; | ||
export { createTranslator, hasLocale } from './core.js'; | ||
@@ -3,0 +3,0 @@ export { IntlProvider, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations } from './react.js'; |
import { createContext, useContext, useMemo, useState, useEffect } from 'react'; | ||
import { d as createCache, b as createIntlFormatters, i as initializeConfig, r as resolveNamespace, I as IntlError, a as IntlErrorCode, e as createBaseTranslator, c as createFormatter } from './initializeConfig-fLcuxncj.js'; | ||
import { d as createCache, b as createIntlFormatters, i as initializeConfig, r as resolveNamespace, I as IntlError, a as IntlErrorCode, e as createBaseTranslator, c as createFormatter } from './initializeConfig-DNjOIggo.js'; | ||
import { jsx } from 'react/jsx-runtime'; | ||
@@ -60,3 +60,3 @@ | ||
if (!context) { | ||
throw new Error('No intl context found. Have you configured the provider? See https://next-intl-docs.vercel.app/docs/usage/configuration#server-client-components' ); | ||
throw new Error('No intl context found. Have you configured the provider? See https://next-intl.dev/docs/usage/configuration#server-client-components' ); | ||
} | ||
@@ -86,3 +86,3 @@ return context; | ||
hasWarnedForMissingTimezone = true; | ||
onError(new IntlError(IntlErrorCode.ENVIRONMENT_FALLBACK, `There is no \`timeZone\` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl-docs.vercel.app/docs/configuration#time-zone` )); | ||
onError(new IntlError(IntlErrorCode.ENVIRONMENT_FALLBACK, `There is no \`timeZone\` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl.dev/docs/configuration#time-zone` )); | ||
} | ||
@@ -135,3 +135,3 @@ const translate = useMemo(() => createBaseTranslator({ | ||
/** | ||
* @see https://next-intl-docs.vercel.app/docs/usage/dates-times#relative-times-usenow | ||
* @see https://next-intl.dev/docs/usage/dates-times#relative-times-usenow | ||
*/ | ||
@@ -163,3 +163,3 @@ function useNow(options) { | ||
if (!context.messages) { | ||
throw new Error('No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages' ); | ||
throw new Error('No messages found. Have you configured them correctly? See https://next-intl.dev/docs/configuration#messages' ); | ||
} | ||
@@ -166,0 +166,0 @@ return context.messages; |
@@ -5,3 +5,3 @@ /** | ||
* Optionally, messages can be strictly-typed in order to get type safety for message | ||
* namespaces and keys. See https://next-intl-docs.vercel.app/docs/usage/typescript | ||
* namespaces and keys. See https://next-intl.dev/docs/usage/typescript | ||
*/ | ||
@@ -8,0 +8,0 @@ type AbstractIntlMessages = { |
@@ -8,12 +8,15 @@ import type { ReactNode } from 'react'; | ||
import type { MessageKeys, NamespaceKeys, NestedKeyOf, NestedValueOf } from './MessageKeys.tsx'; | ||
import type { ICUArg, MarkupTagsFunction, RichTagsFunction } from './TranslationValues.tsx'; | ||
import type { MarkupTagsFunction, RichTagsFunction, TranslationValues } from './TranslationValues.tsx'; | ||
import { type Formatters, type IntlCache } from './formatters.tsx'; | ||
import type { Prettify } from './types.tsx'; | ||
type ICUArgsWithTags<MessageString extends string, TagsFn extends RichTagsFunction | MarkupTagsFunction = never> = ICUArgs<MessageString, { | ||
ICUArgument: string | number | boolean | Date; | ||
ICUArgument: string; | ||
ICUNumberArgument: number; | ||
ICUDateArgument: Date | number; | ||
ICUDateArgument: Date; | ||
}> & ([TagsFn] extends [never] ? {} : ICUTags<MessageString, TagsFn>); | ||
type OnlyOptional<T> = Partial<T> extends T ? true : false; | ||
type TranslateArgs<Value extends string, TagsFn extends RichTagsFunction | MarkupTagsFunction = never> = string extends Value ? [values?: Record<string, ICUArg | TagsFn>, formats?: Formats] : (Value extends any ? (key: ICUArgsWithTags<Value, TagsFn>) => void : never) extends (key: infer Args) => void ? OnlyOptional<Args> extends true ? [values?: undefined, formats?: Formats] : [values: Prettify<Args>, formats?: Formats] : never; | ||
type TranslateArgs<Value extends string, TagsFn extends RichTagsFunction | MarkupTagsFunction = never> = string extends Value ? [ | ||
values?: Record<string, TranslationValues[string] | TagsFn>, | ||
formats?: Formats | ||
] : (Value extends any ? (key: ICUArgsWithTags<Value, TagsFn>) => void : never) extends (key: infer Args) => void ? OnlyOptional<Args> extends true ? [values?: undefined, formats?: Formats] : [values: Prettify<Args>, formats?: Formats] : never; | ||
type NamespacedMessageKeys<TranslatorMessages extends Messages, Namespace extends NamespaceKeys<TranslatorMessages, NestedKeyOf<TranslatorMessages>> = never> = MessageKeys<NestedValueOf<{ | ||
@@ -20,0 +23,0 @@ '!': TranslatorMessages; |
export type { default as AbstractIntlMessages } from './AbstractIntlMessages.tsx'; | ||
export type { TranslationValues, ICUArg, RichTranslationValues, MarkupTranslationValues, RichTagsFunction, MarkupTagsFunction } from './TranslationValues.tsx'; | ||
export type { TranslationValues, RichTranslationValues, MarkupTranslationValues, RichTagsFunction, MarkupTagsFunction } from './TranslationValues.tsx'; | ||
export type { default as Formats } from './Formats.tsx'; | ||
@@ -4,0 +4,0 @@ export type { default as IntlConfig } from './IntlConfig.tsx'; |
import type { ReactNode } from 'react'; | ||
export type ICUArg = string | number | boolean | Date; | ||
export type TranslationValues = Record<string, ICUArg>; | ||
export type TranslationValues = Record<string, string | number | Date>; | ||
export type RichTagsFunction = (chunks: ReactNode) => ReactNode; | ||
export type MarkupTagsFunction = (chunks: string) => string; | ||
export type RichTranslationValues = Record<string, ICUArg | RichTagsFunction>; | ||
export type MarkupTranslationValues = Record<string, ICUArg | MarkupTagsFunction>; | ||
export type RichTranslationValues = Record<string, TranslationValues[string] | RichTagsFunction>; | ||
export type MarkupTranslationValues = Record<string, TranslationValues[string] | MarkupTagsFunction>; |
@@ -5,5 +5,5 @@ type Options = { | ||
/** | ||
* @see https://next-intl-docs.vercel.app/docs/usage/dates-times#relative-times-usenow | ||
* @see https://next-intl.dev/docs/usage/dates-times#relative-times-usenow | ||
*/ | ||
export default function useNow(options?: Options): Date; | ||
export {}; |
{ | ||
"name": "use-intl", | ||
"version": "4.0.0-beta-7b755e9", | ||
"version": "4.0.0-beta-7e7011d", | ||
"sideEffects": false, | ||
@@ -8,3 +8,3 @@ "author": "Jan Amann <jan@amann.work>", | ||
"license": "MIT", | ||
"homepage": "https://next-intl-docs.vercel.app/", | ||
"homepage": "https://next-intl.dev", | ||
"repository": { | ||
@@ -66,5 +66,5 @@ "type": "git", | ||
"peerDependencies": { | ||
"react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0" | ||
"react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0" | ||
}, | ||
"gitHead": "ff4d528b0becc2d1c27232ea8f53351ff655cc50" | ||
"gitHead": "8b5006b6a3d8bec471a5e9a4564c31befb5241b0" | ||
} |
@@ -83,2 +83,2 @@ # 🌐 use-intl | ||
### [→ Read the docs](https://next-intl-docs.vercel.app/docs/environments/core-library) | ||
### [→ Read the docs](https://next-intl.dev/docs/environments/core-library) |
1468
82704