Socket
Socket
Sign inDemoInstall

@lingui/core

Package Overview
Dependencies
Maintainers
3
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lingui/core - npm Package Compare versions

Comparing version 3.17.0 to 3.17.1

59

build/cjs/compile.js
'use strict';
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var parser = require('@messageformat/parser');
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
// [Tokens] -> (CTX -> String)
function processTokens(tokens, mapText) {
if (!tokens.filter(function (token) {
return token.type !== "content";
}).length) {
return tokens.map(function (token) {
if (!tokens.filter(token => token.type !== "content").length) {
return tokens.map(token => mapText(token.value)).join("");
}
return tokens.map(token => {
if (token.type === "content") {
return mapText(token.value);
}).join("");
}
return tokens.map(function (token) {
if (token.type === 'content') {
return mapText(token.value); // # in plural case
// # in plural case
} else if (token.type === "octothorpe") {
return "#"; // simple argument
return "#";
// simple argument
} else if (token.type === "argument") {
return [token.arg]; // argument with custom format (date, number)
return [token.arg];
// argument with custom format (date, number)
} else if (token.type === "function") {
var _token$param;
var _param = token === null || token === void 0 ? void 0 : (_token$param = token.param) === null || _token$param === void 0 ? void 0 : _token$param[0];
const _param = token === null || token === void 0 ? void 0 : (_token$param = token.param) === null || _token$param === void 0 ? void 0 : _token$param[0];
if (_param) {

@@ -38,27 +32,24 @@ return [token.arg, token.key, _param.value.trim()];

}
const offset = token.pluralOffset;
var offset = token.pluralOffset; // complex argument with cases
var formatProps = {};
token.cases.forEach(function (item) {
// complex argument with cases
const formatProps = {};
token.cases.forEach(item => {
formatProps[item.key.replace(/^=(.)+/, "$1")] = processTokens(item.tokens, mapText);
});
return [token.arg, token.type, _objectSpread({
offset: offset
}, formatProps)];
return [token.arg, token.type, {
offset,
...formatProps
}];
});
} // Message -> (Params -> String)
}
// Message -> (Params -> String)
/** @internal */
function compileMessage(message) {
var mapText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (v) {
return v;
};
let mapText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : v => v;
try {
return processTokens(parser.parse(message), mapText);
} catch (e) {
console.error("".concat(e.message, " \n\nMessage: ").concat(message));
console.error(`${e.message} \n\nMessage: ${message}`);
return message;

@@ -65,0 +56,0 @@ }

'use strict';
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
var _createClass = require('@babel/runtime/helpers/createClass');
var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
var _inherits = require('@babel/runtime/helpers/inherits');
var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var compile = require('@lingui/core/compile');
var isString = function isString(s) {
return typeof s === "string";
};
var isFunction = function isFunction(f) {
return typeof f === "function";
};
const isString = s => typeof s === "string";
const isFunction = f => typeof f === "function";
/** Memoized cache */
var numberFormats = new Map();
var dateFormats = new Map();
const numberFormats = new Map();
const dateFormats = new Map();
function date(locales) {
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var memoize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
return function (value) {
let format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let memoize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
return value => {
if (isString(value)) value = new Date(value);
if (memoize) {
var key = cacheKey(locales, format);
var cachedFormatter = dateFormats.get(key);
const key = cacheKey(locales, format);
const cachedFormatter = dateFormats.get(key);
if (cachedFormatter) {
return cachedFormatter.format(value);
}
var _formatter = new Intl.DateTimeFormat(locales, format);
dateFormats.set(key, _formatter);
return _formatter.format(value);
const formatter = new Intl.DateTimeFormat(locales, format);
dateFormats.set(key, formatter);
return formatter.format(value);
}
var formatter = new Intl.DateTimeFormat(locales, format);
const formatter = new Intl.DateTimeFormat(locales, format);
return formatter.format(value);

@@ -49,29 +31,25 @@ };

function number(locales) {
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var memoize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
return function (value) {
let format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let memoize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
return value => {
if (memoize) {
var key = cacheKey(locales, format);
var cachedFormatter = numberFormats.get(key);
const key = cacheKey(locales, format);
const cachedFormatter = numberFormats.get(key);
if (cachedFormatter) {
return cachedFormatter.format(value);
}
var _formatter2 = new Intl.NumberFormat(locales, format);
numberFormats.set(key, _formatter2);
return _formatter2.format(value);
const formatter = new Intl.NumberFormat(locales, format);
numberFormats.set(key, formatter);
return formatter.format(value);
}
var formatter = new Intl.NumberFormat(locales, format);
const formatter = new Intl.NumberFormat(locales, format);
return formatter.format(value);
};
}
/** Memoize helpers */
function cacheKey(locales) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var localeKey = Array.isArray(locales) ? locales.sort().join('-') : locales;
return "".concat(localeKey, "-").concat(JSON.stringify(options));
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const localeKey = Array.isArray(locales) ? locales.sort().join("-") : locales;
return `${localeKey}-${JSON.stringify(options)}`;
}

@@ -85,68 +63,52 @@

var UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
var defaultFormats = function defaultFormats(locale, locales) {
var localeData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
const UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
const defaultFormats = function (locale, locales) {
let localeData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
plurals: undefined
};
var formats = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
let formats = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
locales = locales || locale;
var plurals = localeData.plurals;
var style = function style(format) {
return isString(format) ? formats[format] || {
style: format
} : format;
};
var replaceOctothorpe = function replaceOctothorpe(value, message) {
return function (ctx) {
var msg = isFunction(message) ? message(ctx) : message;
var norm = Array.isArray(msg) ? msg : [msg];
var numberFormat = Object.keys(formats).length ? style('number') : {};
var valueStr = number(locales, numberFormat)(value);
return norm.map(function (m) {
return isString(m) ? m.replace("#", valueStr) : m;
});
const {
plurals
} = localeData;
const style = format => isString(format) ? formats[format] || {
style: format
} : format;
const replaceOctothorpe = (value, message) => {
return ctx => {
const msg = isFunction(message) ? message(ctx) : message;
const norm = Array.isArray(msg) ? msg : [msg];
const numberFormat = Object.keys(formats).length ? style("number") : {};
const valueStr = number(locales, numberFormat)(value);
return norm.map(m => isString(m) ? m.replace("#", valueStr) : m);
};
};
if (!plurals) {
console.error("Plurals for locale ".concat(locale, " aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback."));
console.error(`Plurals for locale ${locale} aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback.`);
}
return {
plural: function plural(value, _ref) {
var _ref$offset = _ref.offset,
offset = _ref$offset === void 0 ? 0 : _ref$offset,
rules = _objectWithoutProperties(_ref, ["offset"]);
var message = rules[value] || rules[plurals === null || plurals === void 0 ? void 0 : plurals(value - offset)] || rules.other;
plural: (value, _ref) => {
let {
offset = 0,
...rules
} = _ref;
const message = rules[value] || rules[plurals === null || plurals === void 0 ? void 0 : plurals(value - offset)] || rules.other;
return replaceOctothorpe(value - offset, message);
},
selectordinal: function selectordinal(value, _ref2) {
var _ref2$offset = _ref2.offset,
offset = _ref2$offset === void 0 ? 0 : _ref2$offset,
rules = _objectWithoutProperties(_ref2, ["offset"]);
var message = rules[value] || rules[plurals === null || plurals === void 0 ? void 0 : plurals(value - offset, true)] || rules.other;
selectordinal: (value, _ref2) => {
let {
offset = 0,
...rules
} = _ref2;
const message = rules[value] || rules[plurals === null || plurals === void 0 ? void 0 : plurals(value - offset, true)] || rules.other;
return replaceOctothorpe(value - offset, message);
},
select: function select(value, rules) {
return rules[value] || rules.other;
},
number: function number$1(value, format) {
return number(locales, style(format))(value);
},
date: function date$1(value, format) {
return date(locales, style(format))(value);
},
undefined: function undefined$1(value) {
return value;
}
select: (value, rules) => rules[value] || rules.other,
number: (value, format) => number(locales, style(format))(value),
date: (value, format) => date(locales, style(format))(value),
undefined: value => value
};
}; // Params -> CTX
};
// Params -> CTX
/**

@@ -163,36 +125,24 @@ * Creates a context object, which formats ICU MessageFormat arguments based on

*/
function context(locale, locales, values, formats, localeData) {
var formatters = defaultFormats(locale, locales, localeData, formats);
var ctx = function ctx(name, type, format) {
var value = values[name];
var formatted = formatters[type](value, format);
var message = isFunction(formatted) ? formatted(ctx) : formatted;
const formatters = defaultFormats(locale, locales, localeData, formats);
const ctx = (name, type, format) => {
const value = values[name];
const formatted = formatters[type](value, format);
const message = isFunction(formatted) ? formatted(ctx) : formatted;
return Array.isArray(message) ? message.join("") : message;
};
return ctx;
}
function interpolate(translation, locale, locales, localeData) {
return function (values) {
var formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var ctx = context(locale, locales, values, formats, localeData);
var formatMessage = function formatMessage(message) {
let formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const ctx = context(locale, locales, values, formats, localeData);
const formatMessage = message => {
if (!Array.isArray(message)) return message;
return message.reduce(function (message, token) {
return message.reduce((message, token) => {
if (isString(token)) return message + token;
var _token = _slicedToArray(token, 3),
name = _token[0],
type = _token[1],
format = _token[2];
var interpolatedFormat = {};
const [name, type, format] = token;
let interpolatedFormat = {};
if (format != null && !isString(format)) {
Object.keys(format).forEach(function (key) {
Object.keys(format).forEach(key => {
interpolatedFormat[key] = formatMessage(format[key]);

@@ -203,4 +153,3 @@ });

}
var value = ctx(name, type, interpolatedFormat);
const value = ctx(name, type, interpolatedFormat);
if (value == null) return message;

@@ -210,5 +159,4 @@ return message + value;

};
var result = formatMessage(translation);
if (isString(result) && UNICODE_REGEX.test(result)) return JSON.parse("\"".concat(result.trim(), "\""));
const result = formatMessage(translation);
if (isString(result) && UNICODE_REGEX.test(result)) return JSON.parse(`"${result.trim()}"`);
if (isString(result)) return result.trim();

@@ -219,266 +167,161 @@ return result;

var EventEmitter = /*#__PURE__*/function () {
function EventEmitter() {
_classCallCheck(this, EventEmitter);
_defineProperty(this, "_events", {});
class EventEmitter {
_events = {};
on(event, listener) {
if (!this._hasEvent(event)) this._events[event] = [];
this._events[event].push(listener);
return () => this.removeListener(event, listener);
}
_createClass(EventEmitter, [{
key: "on",
value: function on(event, listener) {
var _this = this;
if (!this._hasEvent(event)) this._events[event] = [];
this._events[event].push(listener);
return function () {
return _this.removeListener(event, listener);
};
removeListener(event, listener) {
if (!this._hasEvent(event)) return;
const index = this._events[event].indexOf(listener);
if (~index) this._events[event].splice(index, 1);
}
emit(event) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
}, {
key: "removeListener",
value: function removeListener(event, listener) {
if (!this._hasEvent(event)) return;
if (!this._hasEvent(event)) return;
this._events[event].map(listener => listener.apply(this, args));
}
_hasEvent(event) {
return Array.isArray(this._events[event]);
}
}
var index = this._events[event].indexOf(listener);
if (~index) this._events[event].splice(index, 1);
class I18n extends EventEmitter {
constructor(params) {
super();
this._messages = {};
this._localeData = {};
if (params.missing != null) this._missing = params.missing;
if (params.messages != null) this.load(params.messages);
if (params.localeData != null) this.loadLocaleData(params.localeData);
if (params.locale != null || params.locales != null) {
this.activate(params.locale, params.locales);
}
}, {
key: "emit",
value: function emit(event) {
var _this2 = this;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
if (!this._hasEvent(event)) return;
this._events[event].map(function (listener) {
return listener.apply(_this2, args);
});
}
get locale() {
return this._locale;
}
get locales() {
return this._locales;
}
get messages() {
return this._messages[this._locale] ?? {};
}
get localeData() {
return this._localeData[this._locale] ?? {};
}
_loadLocaleData(locale, localeData) {
if (this._localeData[locale] == null) {
this._localeData[locale] = localeData;
} else {
Object.assign(this._localeData[locale], localeData);
}
}, {
key: "_hasEvent",
value: function _hasEvent(event) {
return Array.isArray(this._events[event]);
}
loadLocaleData(localeOrAllData, localeData) {
if (localeData != null) {
// loadLocaleData('en', enLocaleData)
// Loading locale data for a single locale.
this._loadLocaleData(localeOrAllData, localeData);
} else {
// loadLocaleData(allLocaleData)
// Loading all locale data at once.
Object.keys(localeOrAllData).forEach(locale => this._loadLocaleData(locale, localeOrAllData[locale]));
}
}]);
return EventEmitter;
}();
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
var I18n = /*#__PURE__*/function (_EventEmitter) {
_inherits(I18n, _EventEmitter);
var _super = _createSuper(I18n);
function I18n(params) {
var _this;
_classCallCheck(this, I18n);
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "_locale", void 0);
_defineProperty(_assertThisInitialized(_this), "_locales", void 0);
_defineProperty(_assertThisInitialized(_this), "_localeData", void 0);
_defineProperty(_assertThisInitialized(_this), "_messages", void 0);
_defineProperty(_assertThisInitialized(_this), "_missing", void 0);
_this._messages = {};
_this._localeData = {};
if (params.missing != null) _this._missing = params.missing;
if (params.messages != null) _this.load(params.messages);
if (params.localeData != null) _this.loadLocaleData(params.localeData);
if (params.locale != null || params.locales != null) {
_this.activate(params.locale, params.locales);
this.emit("change");
}
_load(locale, messages) {
if (this._messages[locale] == null) {
this._messages[locale] = messages;
} else {
Object.assign(this._messages[locale], messages);
}
return _this;
}
_createClass(I18n, [{
key: "_loadLocaleData",
value: function _loadLocaleData(locale, localeData) {
if (this._localeData[locale] == null) {
this._localeData[locale] = localeData;
} else {
Object.assign(this._localeData[locale], localeData);
}
load(localeOrMessages, messages) {
if (messages != null) {
// load('en', catalog)
// Loading a catalog for a single locale.
this._load(localeOrMessages, messages);
} else {
// load(catalogs)
// Loading several locales at once.
Object.keys(localeOrMessages).forEach(locale => this._load(locale, localeOrMessages[locale]));
}
}, {
key: "loadLocaleData",
value: function loadLocaleData(localeOrAllData, localeData) {
var _this2 = this;
if (localeData != null) {
// loadLocaleData('en', enLocaleData)
// Loading locale data for a single locale.
this._loadLocaleData(localeOrAllData, localeData);
} else {
// loadLocaleData(allLocaleData)
// Loading all locale data at once.
Object.keys(localeOrAllData).forEach(function (locale) {
return _this2._loadLocaleData(locale, localeOrAllData[locale]);
});
this.emit("change");
}
activate(locale, locales) {
if (process.env.NODE_ENV !== "production") {
if (!this._messages[locale]) {
console.warn(`Messages for locale "${locale}" not loaded.`);
}
this.emit("change");
}
}, {
key: "_load",
value: function _load(locale, messages) {
if (this._messages[locale] == null) {
this._messages[locale] = messages;
} else {
Object.assign(this._messages[locale], messages);
if (!this._localeData[locale]) {
console.warn(`Locale data for locale "${locale}" not loaded. Plurals won't work correctly.`);
}
}
}, {
key: "load",
value: function load(localeOrMessages, messages) {
var _this3 = this;
this._locale = locale;
this._locales = locales;
this.emit("change");
}
if (messages != null) {
// load('en', catalog)
// Loading a catalog for a single locale.
this._load(localeOrMessages, messages);
} else {
// load(catalogs)
// Loading several locales at once.
Object.keys(localeOrMessages).forEach(function (locale) {
return _this3._load(locale, localeOrMessages[locale]);
});
}
this.emit("change");
// method for translation and formatting
_(id) {
let values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let {
message,
formats,
context
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!isString(id)) {
values = id.values || values;
message = id.message;
context = id.context;
id = id.id;
}
}, {
key: "activate",
value: function activate(locale, locales) {
if (process.env.NODE_ENV !== "production") {
if (!this._messages[locale]) {
console.warn("Messages for locale \"".concat(locale, "\" not loaded."));
}
const messageMissing = !context && !this.messages[id];
const contextualMessageMissing = context && !this.messages[context][id];
const messageUnreachable = contextualMessageMissing || messageMissing;
if (!this._localeData[locale]) {
console.warn("Locale data for locale \"".concat(locale, "\" not loaded. Plurals won't work correctly."));
}
}
this._locale = locale;
this._locales = locales;
this.emit("change");
} // method for translation and formatting
}, {
key: "_",
value: function _(id) {
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
message = _ref.message,
formats = _ref.formats,
context = _ref.context;
if (!isString(id)) {
values = id.values || values;
message = id.message;
context = id.context;
id = id.id;
}
var messageMissing = !context && !this.messages[id];
var contextualMessageMissing = context && !this.messages[context][id];
var messageUnreachable = contextualMessageMissing || messageMissing; // replace missing messages with custom message for debugging
var missing = this._missing;
if (missing && messageUnreachable) {
return isFunction(missing) ? missing(this._locale, id, context) : missing;
}
if (messageUnreachable) {
this.emit("missing", {
id: id,
context: context,
locale: this._locale
});
}
var translation;
if (context && !contextualMessageMissing) {
// context is like a subdirectory of other keys
translation = this.messages[context][id] || message || id;
} else {
translation = this.messages[id] || message || id;
}
if (process.env.NODE_ENV !== "production") {
translation = isString(translation) ? compile.compileMessage(translation) : translation;
} // hack for parsing unicode values inside a string to get parsed in react native environments
if (isString(translation) && UNICODE_REGEX.test(translation)) return JSON.parse("\"".concat(translation, "\""));
if (isString(translation)) return translation;
return interpolate(translation, this._locale, this._locales, this.localeData)(values, formats);
// replace missing messages with custom message for debugging
const missing = this._missing;
if (missing && messageUnreachable) {
return isFunction(missing) ? missing(this._locale, id, context) : missing;
}
}, {
key: "date",
value: function date$1(value, format) {
return date(this._locales || this._locale, format)(value);
if (messageUnreachable) {
this.emit("missing", {
id,
context,
locale: this._locale
});
}
}, {
key: "number",
value: function number$1(value, format) {
return number(this._locales || this._locale, format)(value);
let translation;
if (context && !contextualMessageMissing) {
// context is like a subdirectory of other keys
translation = this.messages[context][id] || message || id;
} else {
translation = this.messages[id] || message || id;
}
}, {
key: "locale",
get: function get() {
return this._locale;
if (process.env.NODE_ENV !== "production") {
translation = isString(translation) ? compile.compileMessage(translation) : translation;
}
}, {
key: "locales",
get: function get() {
return this._locales;
}
}, {
key: "messages",
get: function get() {
var _this$_messages$this$;
return (_this$_messages$this$ = this._messages[this._locale]) !== null && _this$_messages$this$ !== void 0 ? _this$_messages$this$ : {};
}
}, {
key: "localeData",
get: function get() {
var _this$_localeData$thi;
return (_this$_localeData$thi = this._localeData[this._locale]) !== null && _this$_localeData$thi !== void 0 ? _this$_localeData$thi : {};
}
}]);
return I18n;
}(EventEmitter);
// hack for parsing unicode values inside a string to get parsed in react native environments
if (isString(translation) && UNICODE_REGEX.test(translation)) return JSON.parse(`"${translation}"`);
if (isString(translation)) return translation;
return interpolate(translation, this._locale, this._locales, this.localeData)(values, formats);
}
date(value, format) {
return date(this._locales || this._locale, format)(value);
}
number(value, format) {
return number(this._locales || this._locale, format)(value);
}
}
function setupI18n() {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return new I18n(params);
}
var i18n = setupI18n();
const i18n = setupI18n();

@@ -485,0 +328,0 @@ exports.I18n = I18n;

@@ -1,30 +0,24 @@

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { parse } from '@messageformat/parser';
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
// [Tokens] -> (CTX -> String)
function processTokens(tokens, mapText) {
if (!tokens.filter(function (token) {
return token.type !== "content";
}).length) {
return tokens.map(function (token) {
if (!tokens.filter(token => token.type !== "content").length) {
return tokens.map(token => mapText(token.value)).join("");
}
return tokens.map(token => {
if (token.type === "content") {
return mapText(token.value);
}).join("");
}
return tokens.map(function (token) {
if (token.type === 'content') {
return mapText(token.value); // # in plural case
// # in plural case
} else if (token.type === "octothorpe") {
return "#"; // simple argument
return "#";
// simple argument
} else if (token.type === "argument") {
return [token.arg]; // argument with custom format (date, number)
return [token.arg];
// argument with custom format (date, number)
} else if (token.type === "function") {
var _token$param;
var _param = token === null || token === void 0 ? void 0 : (_token$param = token.param) === null || _token$param === void 0 ? void 0 : _token$param[0];
const _param = token === null || token === void 0 ? void 0 : (_token$param = token.param) === null || _token$param === void 0 ? void 0 : _token$param[0];
if (_param) {

@@ -36,27 +30,24 @@ return [token.arg, token.key, _param.value.trim()];

}
const offset = token.pluralOffset;
var offset = token.pluralOffset; // complex argument with cases
var formatProps = {};
token.cases.forEach(function (item) {
// complex argument with cases
const formatProps = {};
token.cases.forEach(item => {
formatProps[item.key.replace(/^=(.)+/, "$1")] = processTokens(item.tokens, mapText);
});
return [token.arg, token.type, _objectSpread({
offset: offset
}, formatProps)];
return [token.arg, token.type, {
offset,
...formatProps
}];
});
} // Message -> (Params -> String)
}
// Message -> (Params -> String)
/** @internal */
function compileMessage(message) {
var mapText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (v) {
return v;
};
let mapText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : v => v;
try {
return processTokens(parse(message), mapText);
} catch (e) {
console.error("".concat(e.message, " \n\nMessage: ").concat(message));
console.error(`${e.message} \n\nMessage: ${message}`);
return message;

@@ -63,0 +54,0 @@ }

@@ -1,43 +0,25 @@

import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
import _createClass from '@babel/runtime/helpers/createClass';
import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
import _inherits from '@babel/runtime/helpers/inherits';
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { compileMessage } from '@lingui/core/compile';
var isString = function isString(s) {
return typeof s === "string";
};
var isFunction = function isFunction(f) {
return typeof f === "function";
};
const isString = s => typeof s === "string";
const isFunction = f => typeof f === "function";
/** Memoized cache */
var numberFormats = new Map();
var dateFormats = new Map();
const numberFormats = new Map();
const dateFormats = new Map();
function date(locales) {
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var memoize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
return function (value) {
let format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let memoize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
return value => {
if (isString(value)) value = new Date(value);
if (memoize) {
var key = cacheKey(locales, format);
var cachedFormatter = dateFormats.get(key);
const key = cacheKey(locales, format);
const cachedFormatter = dateFormats.get(key);
if (cachedFormatter) {
return cachedFormatter.format(value);
}
var _formatter = new Intl.DateTimeFormat(locales, format);
dateFormats.set(key, _formatter);
return _formatter.format(value);
const formatter = new Intl.DateTimeFormat(locales, format);
dateFormats.set(key, formatter);
return formatter.format(value);
}
var formatter = new Intl.DateTimeFormat(locales, format);
const formatter = new Intl.DateTimeFormat(locales, format);
return formatter.format(value);

@@ -47,29 +29,25 @@ };

function number(locales) {
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var memoize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
return function (value) {
let format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let memoize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
return value => {
if (memoize) {
var key = cacheKey(locales, format);
var cachedFormatter = numberFormats.get(key);
const key = cacheKey(locales, format);
const cachedFormatter = numberFormats.get(key);
if (cachedFormatter) {
return cachedFormatter.format(value);
}
var _formatter2 = new Intl.NumberFormat(locales, format);
numberFormats.set(key, _formatter2);
return _formatter2.format(value);
const formatter = new Intl.NumberFormat(locales, format);
numberFormats.set(key, formatter);
return formatter.format(value);
}
var formatter = new Intl.NumberFormat(locales, format);
const formatter = new Intl.NumberFormat(locales, format);
return formatter.format(value);
};
}
/** Memoize helpers */
function cacheKey(locales) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var localeKey = Array.isArray(locales) ? locales.sort().join('-') : locales;
return "".concat(localeKey, "-").concat(JSON.stringify(options));
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const localeKey = Array.isArray(locales) ? locales.sort().join("-") : locales;
return `${localeKey}-${JSON.stringify(options)}`;
}

@@ -83,68 +61,52 @@

var UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
var defaultFormats = function defaultFormats(locale, locales) {
var localeData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
const UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
const defaultFormats = function (locale, locales) {
let localeData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
plurals: undefined
};
var formats = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
let formats = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
locales = locales || locale;
var plurals = localeData.plurals;
var style = function style(format) {
return isString(format) ? formats[format] || {
style: format
} : format;
};
var replaceOctothorpe = function replaceOctothorpe(value, message) {
return function (ctx) {
var msg = isFunction(message) ? message(ctx) : message;
var norm = Array.isArray(msg) ? msg : [msg];
var numberFormat = Object.keys(formats).length ? style('number') : {};
var valueStr = number(locales, numberFormat)(value);
return norm.map(function (m) {
return isString(m) ? m.replace("#", valueStr) : m;
});
const {
plurals
} = localeData;
const style = format => isString(format) ? formats[format] || {
style: format
} : format;
const replaceOctothorpe = (value, message) => {
return ctx => {
const msg = isFunction(message) ? message(ctx) : message;
const norm = Array.isArray(msg) ? msg : [msg];
const numberFormat = Object.keys(formats).length ? style("number") : {};
const valueStr = number(locales, numberFormat)(value);
return norm.map(m => isString(m) ? m.replace("#", valueStr) : m);
};
};
if (!plurals) {
console.error("Plurals for locale ".concat(locale, " aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback."));
console.error(`Plurals for locale ${locale} aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback.`);
}
return {
plural: function plural(value, _ref) {
var _ref$offset = _ref.offset,
offset = _ref$offset === void 0 ? 0 : _ref$offset,
rules = _objectWithoutProperties(_ref, ["offset"]);
var message = rules[value] || rules[plurals === null || plurals === void 0 ? void 0 : plurals(value - offset)] || rules.other;
plural: (value, _ref) => {
let {
offset = 0,
...rules
} = _ref;
const message = rules[value] || rules[plurals === null || plurals === void 0 ? void 0 : plurals(value - offset)] || rules.other;
return replaceOctothorpe(value - offset, message);
},
selectordinal: function selectordinal(value, _ref2) {
var _ref2$offset = _ref2.offset,
offset = _ref2$offset === void 0 ? 0 : _ref2$offset,
rules = _objectWithoutProperties(_ref2, ["offset"]);
var message = rules[value] || rules[plurals === null || plurals === void 0 ? void 0 : plurals(value - offset, true)] || rules.other;
selectordinal: (value, _ref2) => {
let {
offset = 0,
...rules
} = _ref2;
const message = rules[value] || rules[plurals === null || plurals === void 0 ? void 0 : plurals(value - offset, true)] || rules.other;
return replaceOctothorpe(value - offset, message);
},
select: function select(value, rules) {
return rules[value] || rules.other;
},
number: function number$1(value, format) {
return number(locales, style(format))(value);
},
date: function date$1(value, format) {
return date(locales, style(format))(value);
},
undefined: function undefined$1(value) {
return value;
}
select: (value, rules) => rules[value] || rules.other,
number: (value, format) => number(locales, style(format))(value),
date: (value, format) => date(locales, style(format))(value),
undefined: value => value
};
}; // Params -> CTX
};
// Params -> CTX
/**

@@ -161,36 +123,24 @@ * Creates a context object, which formats ICU MessageFormat arguments based on

*/
function context(locale, locales, values, formats, localeData) {
var formatters = defaultFormats(locale, locales, localeData, formats);
var ctx = function ctx(name, type, format) {
var value = values[name];
var formatted = formatters[type](value, format);
var message = isFunction(formatted) ? formatted(ctx) : formatted;
const formatters = defaultFormats(locale, locales, localeData, formats);
const ctx = (name, type, format) => {
const value = values[name];
const formatted = formatters[type](value, format);
const message = isFunction(formatted) ? formatted(ctx) : formatted;
return Array.isArray(message) ? message.join("") : message;
};
return ctx;
}
function interpolate(translation, locale, locales, localeData) {
return function (values) {
var formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var ctx = context(locale, locales, values, formats, localeData);
var formatMessage = function formatMessage(message) {
let formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const ctx = context(locale, locales, values, formats, localeData);
const formatMessage = message => {
if (!Array.isArray(message)) return message;
return message.reduce(function (message, token) {
return message.reduce((message, token) => {
if (isString(token)) return message + token;
var _token = _slicedToArray(token, 3),
name = _token[0],
type = _token[1],
format = _token[2];
var interpolatedFormat = {};
const [name, type, format] = token;
let interpolatedFormat = {};
if (format != null && !isString(format)) {
Object.keys(format).forEach(function (key) {
Object.keys(format).forEach(key => {
interpolatedFormat[key] = formatMessage(format[key]);

@@ -201,4 +151,3 @@ });

}
var value = ctx(name, type, interpolatedFormat);
const value = ctx(name, type, interpolatedFormat);
if (value == null) return message;

@@ -208,5 +157,4 @@ return message + value;

};
var result = formatMessage(translation);
if (isString(result) && UNICODE_REGEX.test(result)) return JSON.parse("\"".concat(result.trim(), "\""));
const result = formatMessage(translation);
if (isString(result) && UNICODE_REGEX.test(result)) return JSON.parse(`"${result.trim()}"`);
if (isString(result)) return result.trim();

@@ -217,268 +165,163 @@ return result;

var EventEmitter = /*#__PURE__*/function () {
function EventEmitter() {
_classCallCheck(this, EventEmitter);
_defineProperty(this, "_events", {});
class EventEmitter {
_events = {};
on(event, listener) {
if (!this._hasEvent(event)) this._events[event] = [];
this._events[event].push(listener);
return () => this.removeListener(event, listener);
}
_createClass(EventEmitter, [{
key: "on",
value: function on(event, listener) {
var _this = this;
if (!this._hasEvent(event)) this._events[event] = [];
this._events[event].push(listener);
return function () {
return _this.removeListener(event, listener);
};
removeListener(event, listener) {
if (!this._hasEvent(event)) return;
const index = this._events[event].indexOf(listener);
if (~index) this._events[event].splice(index, 1);
}
emit(event) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
}, {
key: "removeListener",
value: function removeListener(event, listener) {
if (!this._hasEvent(event)) return;
if (!this._hasEvent(event)) return;
this._events[event].map(listener => listener.apply(this, args));
}
_hasEvent(event) {
return Array.isArray(this._events[event]);
}
}
var index = this._events[event].indexOf(listener);
if (~index) this._events[event].splice(index, 1);
class I18n extends EventEmitter {
constructor(params) {
super();
this._messages = {};
this._localeData = {};
if (params.missing != null) this._missing = params.missing;
if (params.messages != null) this.load(params.messages);
if (params.localeData != null) this.loadLocaleData(params.localeData);
if (params.locale != null || params.locales != null) {
this.activate(params.locale, params.locales);
}
}, {
key: "emit",
value: function emit(event) {
var _this2 = this;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
if (!this._hasEvent(event)) return;
this._events[event].map(function (listener) {
return listener.apply(_this2, args);
});
}
get locale() {
return this._locale;
}
get locales() {
return this._locales;
}
get messages() {
return this._messages[this._locale] ?? {};
}
get localeData() {
return this._localeData[this._locale] ?? {};
}
_loadLocaleData(locale, localeData) {
if (this._localeData[locale] == null) {
this._localeData[locale] = localeData;
} else {
Object.assign(this._localeData[locale], localeData);
}
}, {
key: "_hasEvent",
value: function _hasEvent(event) {
return Array.isArray(this._events[event]);
}
loadLocaleData(localeOrAllData, localeData) {
if (localeData != null) {
// loadLocaleData('en', enLocaleData)
// Loading locale data for a single locale.
this._loadLocaleData(localeOrAllData, localeData);
} else {
// loadLocaleData(allLocaleData)
// Loading all locale data at once.
Object.keys(localeOrAllData).forEach(locale => this._loadLocaleData(locale, localeOrAllData[locale]));
}
}]);
return EventEmitter;
}();
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
var I18n = /*#__PURE__*/function (_EventEmitter) {
_inherits(I18n, _EventEmitter);
var _super = _createSuper(I18n);
function I18n(params) {
var _this;
_classCallCheck(this, I18n);
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "_locale", void 0);
_defineProperty(_assertThisInitialized(_this), "_locales", void 0);
_defineProperty(_assertThisInitialized(_this), "_localeData", void 0);
_defineProperty(_assertThisInitialized(_this), "_messages", void 0);
_defineProperty(_assertThisInitialized(_this), "_missing", void 0);
_this._messages = {};
_this._localeData = {};
if (params.missing != null) _this._missing = params.missing;
if (params.messages != null) _this.load(params.messages);
if (params.localeData != null) _this.loadLocaleData(params.localeData);
if (params.locale != null || params.locales != null) {
_this.activate(params.locale, params.locales);
this.emit("change");
}
_load(locale, messages) {
if (this._messages[locale] == null) {
this._messages[locale] = messages;
} else {
Object.assign(this._messages[locale], messages);
}
return _this;
}
_createClass(I18n, [{
key: "_loadLocaleData",
value: function _loadLocaleData(locale, localeData) {
if (this._localeData[locale] == null) {
this._localeData[locale] = localeData;
} else {
Object.assign(this._localeData[locale], localeData);
}
load(localeOrMessages, messages) {
if (messages != null) {
// load('en', catalog)
// Loading a catalog for a single locale.
this._load(localeOrMessages, messages);
} else {
// load(catalogs)
// Loading several locales at once.
Object.keys(localeOrMessages).forEach(locale => this._load(locale, localeOrMessages[locale]));
}
}, {
key: "loadLocaleData",
value: function loadLocaleData(localeOrAllData, localeData) {
var _this2 = this;
if (localeData != null) {
// loadLocaleData('en', enLocaleData)
// Loading locale data for a single locale.
this._loadLocaleData(localeOrAllData, localeData);
} else {
// loadLocaleData(allLocaleData)
// Loading all locale data at once.
Object.keys(localeOrAllData).forEach(function (locale) {
return _this2._loadLocaleData(locale, localeOrAllData[locale]);
});
this.emit("change");
}
activate(locale, locales) {
if (process.env.NODE_ENV !== "production") {
if (!this._messages[locale]) {
console.warn(`Messages for locale "${locale}" not loaded.`);
}
this.emit("change");
}
}, {
key: "_load",
value: function _load(locale, messages) {
if (this._messages[locale] == null) {
this._messages[locale] = messages;
} else {
Object.assign(this._messages[locale], messages);
if (!this._localeData[locale]) {
console.warn(`Locale data for locale "${locale}" not loaded. Plurals won't work correctly.`);
}
}
}, {
key: "load",
value: function load(localeOrMessages, messages) {
var _this3 = this;
this._locale = locale;
this._locales = locales;
this.emit("change");
}
if (messages != null) {
// load('en', catalog)
// Loading a catalog for a single locale.
this._load(localeOrMessages, messages);
} else {
// load(catalogs)
// Loading several locales at once.
Object.keys(localeOrMessages).forEach(function (locale) {
return _this3._load(locale, localeOrMessages[locale]);
});
}
this.emit("change");
// method for translation and formatting
_(id) {
let values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let {
message,
formats,
context
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!isString(id)) {
values = id.values || values;
message = id.message;
context = id.context;
id = id.id;
}
}, {
key: "activate",
value: function activate(locale, locales) {
if (process.env.NODE_ENV !== "production") {
if (!this._messages[locale]) {
console.warn("Messages for locale \"".concat(locale, "\" not loaded."));
}
const messageMissing = !context && !this.messages[id];
const contextualMessageMissing = context && !this.messages[context][id];
const messageUnreachable = contextualMessageMissing || messageMissing;
if (!this._localeData[locale]) {
console.warn("Locale data for locale \"".concat(locale, "\" not loaded. Plurals won't work correctly."));
}
}
this._locale = locale;
this._locales = locales;
this.emit("change");
} // method for translation and formatting
}, {
key: "_",
value: function _(id) {
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
message = _ref.message,
formats = _ref.formats,
context = _ref.context;
if (!isString(id)) {
values = id.values || values;
message = id.message;
context = id.context;
id = id.id;
}
var messageMissing = !context && !this.messages[id];
var contextualMessageMissing = context && !this.messages[context][id];
var messageUnreachable = contextualMessageMissing || messageMissing; // replace missing messages with custom message for debugging
var missing = this._missing;
if (missing && messageUnreachable) {
return isFunction(missing) ? missing(this._locale, id, context) : missing;
}
if (messageUnreachable) {
this.emit("missing", {
id: id,
context: context,
locale: this._locale
});
}
var translation;
if (context && !contextualMessageMissing) {
// context is like a subdirectory of other keys
translation = this.messages[context][id] || message || id;
} else {
translation = this.messages[id] || message || id;
}
if (process.env.NODE_ENV !== "production") {
translation = isString(translation) ? compileMessage(translation) : translation;
} // hack for parsing unicode values inside a string to get parsed in react native environments
if (isString(translation) && UNICODE_REGEX.test(translation)) return JSON.parse("\"".concat(translation, "\""));
if (isString(translation)) return translation;
return interpolate(translation, this._locale, this._locales, this.localeData)(values, formats);
// replace missing messages with custom message for debugging
const missing = this._missing;
if (missing && messageUnreachable) {
return isFunction(missing) ? missing(this._locale, id, context) : missing;
}
}, {
key: "date",
value: function date$1(value, format) {
return date(this._locales || this._locale, format)(value);
if (messageUnreachable) {
this.emit("missing", {
id,
context,
locale: this._locale
});
}
}, {
key: "number",
value: function number$1(value, format) {
return number(this._locales || this._locale, format)(value);
let translation;
if (context && !contextualMessageMissing) {
// context is like a subdirectory of other keys
translation = this.messages[context][id] || message || id;
} else {
translation = this.messages[id] || message || id;
}
}, {
key: "locale",
get: function get() {
return this._locale;
if (process.env.NODE_ENV !== "production") {
translation = isString(translation) ? compileMessage(translation) : translation;
}
}, {
key: "locales",
get: function get() {
return this._locales;
}
}, {
key: "messages",
get: function get() {
var _this$_messages$this$;
return (_this$_messages$this$ = this._messages[this._locale]) !== null && _this$_messages$this$ !== void 0 ? _this$_messages$this$ : {};
}
}, {
key: "localeData",
get: function get() {
var _this$_localeData$thi;
return (_this$_localeData$thi = this._localeData[this._locale]) !== null && _this$_localeData$thi !== void 0 ? _this$_localeData$thi : {};
}
}]);
return I18n;
}(EventEmitter);
// hack for parsing unicode values inside a string to get parsed in react native environments
if (isString(translation) && UNICODE_REGEX.test(translation)) return JSON.parse(`"${translation}"`);
if (isString(translation)) return translation;
return interpolate(translation, this._locale, this._locales, this.localeData)(values, formats);
}
date(value, format) {
return date(this._locales || this._locale, format)(value);
}
number(value, format) {
return number(this._locales || this._locale, format)(value);
}
}
function setupI18n() {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return new I18n(params);
}
var i18n = setupI18n();
const i18n = setupI18n();
export { I18n, formats, i18n, setupI18n };
//# sourceMappingURL=index.js.map

@@ -13,3 +13,3 @@ import { PluralCategory } from 'make-plural';

declare type MessageOptions = {
type MessageOptions = {
message?: string;

@@ -19,18 +19,18 @@ context?: string;

};
declare type Locale = string;
declare type Locales = Locale | Locale[];
declare type Formats = Record<string, Intl.DateTimeFormatOptions | Intl.NumberFormatOptions>;
declare type Values = Record<string, unknown>;
declare type LocaleData = {
type Locale = string;
type Locales = Locale | Locale[];
type Formats = Record<string, Intl.DateTimeFormatOptions | Intl.NumberFormatOptions>;
type Values = Record<string, unknown>;
type LocaleData = {
plurals?: (n: number, ordinal?: boolean) => PluralCategory;
};
declare type AllLocaleData = Record<Locale, LocaleData>;
declare type CompiledIcuChoices = Record<string, CompiledMessage> & {
type AllLocaleData = Record<Locale, LocaleData>;
type CompiledIcuChoices = Record<string, CompiledMessage> & {
offset: number;
};
declare type CompiledMessageToken = string | [name: string, type?: string, format?: null | string | CompiledIcuChoices];
declare type CompiledMessage = string | CompiledMessageToken[];
declare type Messages = Record<string, CompiledMessage>;
declare type AllMessages = Record<Locale, Messages>;
declare type MessageDescriptor = {
type CompiledMessageToken = string | [name: string, type?: string, format?: null | string | CompiledIcuChoices];
type CompiledMessage = string | CompiledMessageToken[];
type Messages = Record<string, CompiledMessage>;
type AllMessages = Record<Locale, Messages>;
type MessageDescriptor = {
id?: string;

@@ -42,3 +42,3 @@ comment?: string;

};
declare type MissingMessageEvent = {
type MissingMessageEvent = {
locale: Locale;

@@ -48,3 +48,3 @@ id: string;

};
declare type setupI18nProps = {
type setupI18nProps = {
locale?: Locale;

@@ -56,3 +56,3 @@ locales?: Locales;

};
declare type Events = {
type Events = {
change: () => void;

@@ -59,0 +59,0 @@ missing: (event: MissingMessageEvent) => void;

@@ -6,2 +6,10 @@ # Change Log

## [3.17.1](https://github.com/lingui/js-lingui/compare/v3.17.0...v3.17.1) (2023-02-07)
**Note:** Version bump only for package @lingui/core
# [3.17.0](https://github.com/lingui/js-lingui/compare/v3.16.1...v3.17.0) (2023-02-01)

@@ -8,0 +16,0 @@

{
"name": "@lingui/core",
"version": "3.17.0",
"version": "3.17.1",
"sideEffects": false,

@@ -62,7 +62,7 @@ "description": "I18n tools for javascript",

"dependencies": {
"@babel/runtime": "^7.11.2",
"@babel/runtime": "^7.20.13",
"@messageformat/parser": "^5.0.0",
"make-plural": "^6.2.2"
},
"gitHead": "1c8bc46213b35b25da8fe7a80ddcf6f6a5d9d539"
"gitHead": "76ef4e8d1c668578ce2c3829ebf35d22ca5e679c"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc