@formatjs/intl
Advanced tools
Comparing version 1.4.16 to 1.5.0
import { Formatters, MessageDescriptor, CustomFormats, OnErrorFn } from './types'; | ||
import { FormatXMLElementFn, PrimitiveType } from 'intl-messageformat'; | ||
import { FormatXMLElementFn, PrimitiveType, Options } from 'intl-messageformat'; | ||
import { MessageFormatElement } from 'intl-messageformat-parser'; | ||
@@ -12,3 +12,3 @@ export declare function formatMessage(config: { | ||
onError: OnErrorFn; | ||
}, state: Formatters, messageDescriptor?: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>): string; | ||
}, state: Formatters, messageDescriptor?: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: Options): string; | ||
//# sourceMappingURL=message.d.ts.map |
@@ -26,3 +26,3 @@ import { __assign } from "tslib"; | ||
} | ||
export function formatMessage(_a, state, messageDescriptor, values) { | ||
export function formatMessage(_a, state, messageDescriptor, values, opts) { | ||
var locale = _a.locale, formats = _a.formats, messages = _a.messages, defaultLocale = _a.defaultLocale, defaultFormats = _a.defaultFormats, onError = _a.onError, timeZone = _a.timeZone, defaultRichTextElements = _a.defaultRichTextElements; | ||
@@ -67,3 +67,3 @@ if (messageDescriptor === void 0) { messageDescriptor = { id: '' }; } | ||
try { | ||
var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats); | ||
var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts); | ||
return formatter.format(values); | ||
@@ -70,0 +70,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { IntlMessageFormat, Formats, PrimitiveType, FormatXMLElementFn, FormatError } from 'intl-messageformat'; | ||
import { IntlMessageFormat, Formats, PrimitiveType, FormatXMLElementFn, FormatError, Options as IntlMessageFormatOptions } from 'intl-messageformat'; | ||
import IntlRelativeTimeFormat from '@formatjs/intl-relativetimeformat'; | ||
@@ -48,4 +48,4 @@ import { DateTimeFormat } from '@formatjs/ecma402-abstract'; | ||
formatPlural(value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>): string; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T, R>>): R; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T, R>>, opts?: IntlMessageFormatOptions): R; | ||
formatList(values: Array<string>, opts?: FormatListOptions): string; | ||
@@ -52,0 +52,0 @@ formatList(values: Array<string | T>, opts?: FormatListOptions): T | string | Array<string | T>; |
{ | ||
"name": "@formatjs/intl", | ||
"version": "1.4.16", | ||
"version": "1.5.0", | ||
"description": "Internationalize JS apps. This library provides an API to format dates, numbers, and strings, including pluralization and handling translations.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import { Formatters, MessageDescriptor, CustomFormats, OnErrorFn } from './types'; | ||
import { FormatXMLElementFn, PrimitiveType } from 'intl-messageformat'; | ||
import { FormatXMLElementFn, PrimitiveType, Options } from 'intl-messageformat'; | ||
import { MessageFormatElement } from 'intl-messageformat-parser'; | ||
@@ -12,3 +12,3 @@ export declare function formatMessage(config: { | ||
onError: OnErrorFn; | ||
}, state: Formatters, messageDescriptor?: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>): string; | ||
}, state: Formatters, messageDescriptor?: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: Options): string; | ||
//# sourceMappingURL=message.d.ts.map |
@@ -29,3 +29,3 @@ "use strict"; | ||
} | ||
function formatMessage(_a, state, messageDescriptor, values) { | ||
function formatMessage(_a, state, messageDescriptor, values, opts) { | ||
var locale = _a.locale, formats = _a.formats, messages = _a.messages, defaultLocale = _a.defaultLocale, defaultFormats = _a.defaultFormats, onError = _a.onError, timeZone = _a.timeZone, defaultRichTextElements = _a.defaultRichTextElements; | ||
@@ -70,3 +70,3 @@ if (messageDescriptor === void 0) { messageDescriptor = { id: '' }; } | ||
try { | ||
var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats); | ||
var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts); | ||
return formatter.format(values); | ||
@@ -73,0 +73,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { IntlMessageFormat, Formats, PrimitiveType, FormatXMLElementFn, FormatError } from 'intl-messageformat'; | ||
import { IntlMessageFormat, Formats, PrimitiveType, FormatXMLElementFn, FormatError, Options as IntlMessageFormatOptions } from 'intl-messageformat'; | ||
import IntlRelativeTimeFormat from '@formatjs/intl-relativetimeformat'; | ||
@@ -48,4 +48,4 @@ import { DateTimeFormat } from '@formatjs/ecma402-abstract'; | ||
formatPlural(value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>): string; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T, R>>): R; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T, R>>, opts?: IntlMessageFormatOptions): R; | ||
formatList(values: Array<string>, opts?: FormatListOptions): string; | ||
@@ -52,0 +52,0 @@ formatList(values: Array<string | T>, opts?: FormatListOptions): T | string | Array<string | T>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126875