🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@formatjs/intl

Package Overview
Dependencies
Maintainers
3
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formatjs/intl - npm Package Compare versions

Comparing version

to
2.2.3

1

index.d.ts

@@ -8,2 +8,3 @@ import { MessageDescriptor } from './src/types';

export { formatMessage } from './src/message';
export type { FormatMessageFn } from './src/message';
export { formatDate, formatDateToParts, formatTime, formatTimeToParts, } from './src/dateTime';

@@ -10,0 +11,0 @@ export { formatDisplayName } from './src/displayName';

@@ -8,2 +8,3 @@ import { MessageDescriptor } from './src/types';

export { formatMessage } from './src/message';
export type { FormatMessageFn } from './src/message';
export { formatDate, formatDateToParts, formatTime, formatTimeToParts, } from './src/dateTime';

@@ -10,0 +11,0 @@ export { formatDisplayName } from './src/displayName';

14

lib/src/error.js

@@ -19,3 +19,3 @@ import { __extends } from "tslib";

: undefined;
_this = _super.call(this, "[@formatjs/intl Error ".concat(code, "] ").concat(message, " \n").concat(err ? "\n".concat(err.message, "\n").concat(err.stack) : '')) || this;
_this = _super.call(this, "[@formatjs/intl Error ".concat(code, "] ").concat(message, "\n").concat(err ? "\n".concat(err.message, "\n").concat(err.stack) : '')) || this;
_this.code = code;

@@ -59,3 +59,3 @@ // @ts-ignore just so we don't need to declare dep on @types/node

function IntlFormatError(message, locale, exception) {
return _super.call(this, IntlErrorCode.FORMAT_ERROR, "".concat(message, " \nLocale: ").concat(locale, "\n"), exception) || this;
return _super.call(this, IntlErrorCode.FORMAT_ERROR, "".concat(message, "\nLocale: ").concat(locale, "\n"), exception) || this;
}

@@ -68,3 +68,3 @@ return IntlFormatError;

function MessageFormatError(message, locale, descriptor, exception) {
var _this = _super.call(this, "".concat(message, " \nMessageID: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.id, "\nDefault Message: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage, "\nDescription: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.description, " \n"), locale, exception) || this;
var _this = _super.call(this, "".concat(message, "\nMessageID: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.id, "\nDefault Message: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage, "\nDescription: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.description, "\n"), locale, exception) || this;
_this.descriptor = descriptor;

@@ -79,3 +79,9 @@ return _this;

function MissingTranslationError(descriptor, locale) {
var _this = _super.call(this, IntlErrorCode.MISSING_TRANSLATION, "Missing message: \"".concat(descriptor.id, "\" for locale \"").concat(locale, "\", using ").concat(descriptor.defaultMessage ? 'default message' : 'id', " as fallback.")) || this;
var _this = _super.call(this, IntlErrorCode.MISSING_TRANSLATION, "Missing message: \"".concat(descriptor.id, "\" for locale \"").concat(locale, "\", using ").concat(descriptor.defaultMessage
? "default message (".concat(typeof descriptor.defaultMessage === 'string'
? descriptor.defaultMessage
: descriptor.defaultMessage
.map(function (e) { var _a; return (_a = e.value) !== null && _a !== void 0 ? _a : JSON.stringify(e); })
.join(), ")")
: 'id', " as fallback.")) || this;
_this.descriptor = descriptor;

@@ -82,0 +88,0 @@ return _this;

import { Formatters, MessageDescriptor, CustomFormats, OnErrorFn } from './types';
import { FormatXMLElementFn, PrimitiveType, Options } from 'intl-messageformat';
import { FormatXMLElementFn, PrimitiveType, Formatters as IntlMessageFormatFormatters, Options } from 'intl-messageformat';
import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
export declare function formatMessage(config: {
export declare type FormatMessageFn<T> = ({ locale, formats, messages, defaultLocale, defaultFormats, fallbackOnEmptyString, onError, timeZone, defaultRichTextElements, }: {
locale: string;

@@ -11,4 +11,7 @@ timeZone?: string;

defaultFormats: CustomFormats;
defaultRichTextElements?: Record<string, FormatXMLElementFn<T>>;
fallbackOnEmptyString?: boolean;
onError: OnErrorFn;
}, state: Formatters, messageDescriptor?: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: Options): string;
}, state: IntlMessageFormatFormatters & Pick<Formatters, 'getMessageFormat'>, messageDescriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: Options) => T extends string ? string : Array<T | string> | string | T;
export declare const formatMessage: FormatMessageFn<any>;
//# sourceMappingURL=message.d.ts.map

@@ -26,3 +26,3 @@ import { __assign } from "tslib";

}
export function formatMessage(_a, state, messageDescriptor, values, opts) {
export var formatMessage = function (_a, state, messageDescriptor, values, opts) {
var locale = _a.locale, formats = _a.formats, messages = _a.messages, defaultLocale = _a.defaultLocale, defaultFormats = _a.defaultFormats, fallbackOnEmptyString = _a.fallbackOnEmptyString, onError = _a.onError, timeZone = _a.timeZone, defaultRichTextElements = _a.defaultRichTextElements;

@@ -104,2 +104,2 @@ if (messageDescriptor === void 0) { messageDescriptor = { id: '' }; }

return id;
}
};

@@ -1,2 +0,2 @@

import { IntlMessageFormat, Formats, PrimitiveType, FormatXMLElementFn, FormatError, Options as IntlMessageFormatOptions } from 'intl-messageformat';
import { IntlMessageFormat, Formats, FormatXMLElementFn, FormatError, PrimitiveType, Options as IntlMessageFormatOptions } from 'intl-messageformat';
import { DateTimeFormat } from '@formatjs/ecma402-abstract';

@@ -3,0 +3,0 @@ import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';

{
"name": "@formatjs/intl",
"version": "2.2.1",
"version": "2.2.3",
"description": "Internationalize JS apps. This library provides an API to format dates, numbers, and strings, including pluralization and handling translations.",

@@ -32,9 +32,9 @@ "keywords": [

"dependencies": {
"@formatjs/ecma402-abstract": "1.11.4",
"@formatjs/fast-memoize": "1.2.1",
"@formatjs/icu-messageformat-parser": "2.1.0",
"@formatjs/intl-displaynames": "5.4.3",
"@formatjs/intl-listformat": "6.5.3",
"intl-messageformat": "9.13.0",
"tslib": "^2.1.0"
"@formatjs/ecma402-abstract": "1.11.6",
"@formatjs/fast-memoize": "1.2.3",
"@formatjs/icu-messageformat-parser": "2.1.2",
"@formatjs/intl-displaynames": "6.0.1",
"@formatjs/intl-listformat": "7.0.1",
"intl-messageformat": "10.0.1",
"tslib": "2.4.0"
},

@@ -41,0 +41,0 @@ "peerDependencies": {

@@ -22,3 +22,3 @@ "use strict";

: undefined;
_this = _super.call(this, "[@formatjs/intl Error ".concat(code, "] ").concat(message, " \n").concat(err ? "\n".concat(err.message, "\n").concat(err.stack) : '')) || this;
_this = _super.call(this, "[@formatjs/intl Error ".concat(code, "] ").concat(message, "\n").concat(err ? "\n".concat(err.message, "\n").concat(err.stack) : '')) || this;
_this.code = code;

@@ -62,3 +62,3 @@ // @ts-ignore just so we don't need to declare dep on @types/node

function IntlFormatError(message, locale, exception) {
return _super.call(this, IntlErrorCode.FORMAT_ERROR, "".concat(message, " \nLocale: ").concat(locale, "\n"), exception) || this;
return _super.call(this, IntlErrorCode.FORMAT_ERROR, "".concat(message, "\nLocale: ").concat(locale, "\n"), exception) || this;
}

@@ -71,3 +71,3 @@ return IntlFormatError;

function MessageFormatError(message, locale, descriptor, exception) {
var _this = _super.call(this, "".concat(message, " \nMessageID: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.id, "\nDefault Message: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage, "\nDescription: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.description, " \n"), locale, exception) || this;
var _this = _super.call(this, "".concat(message, "\nMessageID: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.id, "\nDefault Message: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage, "\nDescription: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.description, "\n"), locale, exception) || this;
_this.descriptor = descriptor;

@@ -82,3 +82,9 @@ return _this;

function MissingTranslationError(descriptor, locale) {
var _this = _super.call(this, IntlErrorCode.MISSING_TRANSLATION, "Missing message: \"".concat(descriptor.id, "\" for locale \"").concat(locale, "\", using ").concat(descriptor.defaultMessage ? 'default message' : 'id', " as fallback.")) || this;
var _this = _super.call(this, IntlErrorCode.MISSING_TRANSLATION, "Missing message: \"".concat(descriptor.id, "\" for locale \"").concat(locale, "\", using ").concat(descriptor.defaultMessage
? "default message (".concat(typeof descriptor.defaultMessage === 'string'
? descriptor.defaultMessage
: descriptor.defaultMessage
.map(function (e) { var _a; return (_a = e.value) !== null && _a !== void 0 ? _a : JSON.stringify(e); })
.join(), ")")
: 'id', " as fallback.")) || this;
_this.descriptor = descriptor;

@@ -85,0 +91,0 @@ return _this;

import { Formatters, MessageDescriptor, CustomFormats, OnErrorFn } from './types';
import { FormatXMLElementFn, PrimitiveType, Options } from 'intl-messageformat';
import { FormatXMLElementFn, PrimitiveType, Formatters as IntlMessageFormatFormatters, Options } from 'intl-messageformat';
import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
export declare function formatMessage(config: {
export declare type FormatMessageFn<T> = ({ locale, formats, messages, defaultLocale, defaultFormats, fallbackOnEmptyString, onError, timeZone, defaultRichTextElements, }: {
locale: string;

@@ -11,4 +11,7 @@ timeZone?: string;

defaultFormats: CustomFormats;
defaultRichTextElements?: Record<string, FormatXMLElementFn<T>>;
fallbackOnEmptyString?: boolean;
onError: OnErrorFn;
}, state: Formatters, messageDescriptor?: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: Options): string;
}, state: IntlMessageFormatFormatters & Pick<Formatters, 'getMessageFormat'>, messageDescriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: Options) => T extends string ? string : Array<T | string> | string | T;
export declare const formatMessage: FormatMessageFn<any>;
//# sourceMappingURL=message.d.ts.map

@@ -29,3 +29,3 @@ "use strict";

}
function formatMessage(_a, state, messageDescriptor, values, opts) {
var formatMessage = function (_a, state, messageDescriptor, values, opts) {
var locale = _a.locale, formats = _a.formats, messages = _a.messages, defaultLocale = _a.defaultLocale, defaultFormats = _a.defaultFormats, fallbackOnEmptyString = _a.fallbackOnEmptyString, onError = _a.onError, timeZone = _a.timeZone, defaultRichTextElements = _a.defaultRichTextElements;

@@ -107,3 +107,3 @@ if (messageDescriptor === void 0) { messageDescriptor = { id: '' }; }

return id;
}
};
exports.formatMessage = formatMessage;

@@ -1,2 +0,2 @@

import { IntlMessageFormat, Formats, PrimitiveType, FormatXMLElementFn, FormatError, Options as IntlMessageFormatOptions } from 'intl-messageformat';
import { IntlMessageFormat, Formats, FormatXMLElementFn, FormatError, PrimitiveType, Options as IntlMessageFormatOptions } from 'intl-messageformat';
import { DateTimeFormat } from '@formatjs/ecma402-abstract';

@@ -3,0 +3,0 @@ import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet