@wordpress/i18n
Advanced tools
Comparing version 3.20.0 to 4.0.0
@@ -1,7 +0,1 @@ | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
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; } | ||
/** | ||
@@ -22,8 +16,9 @@ * External dependencies | ||
var DEFAULT_LOCALE_DATA = { | ||
const DEFAULT_LOCALE_DATA = { | ||
'': { | ||
/** @param {number} n */ | ||
plural_forms: function plural_forms(n) { | ||
plural_forms(n) { | ||
return n === 1 ? 0 : 1; | ||
} | ||
} | ||
@@ -36,3 +31,3 @@ }; | ||
var I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/; | ||
const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/; | ||
/** | ||
@@ -162,3 +157,3 @@ * @typedef {(domain?: string) => LocaleData} GetLocaleData | ||
export var createI18n = function createI18n(initialData, initialDomain, hooks) { | ||
export const createI18n = (initialData, initialDomain, hooks) => { | ||
/** | ||
@@ -169,9 +164,7 @@ * The underlying instance of Tannin to which exported functions interface. | ||
*/ | ||
var tannin = new Tannin({}); | ||
var listeners = new Set(); | ||
const tannin = new Tannin({}); | ||
const listeners = new Set(); | ||
var notifyListeners = function notifyListeners() { | ||
listeners.forEach(function (listener) { | ||
return listener(); | ||
}); | ||
const notifyListeners = () => { | ||
listeners.forEach(listener => listener()); | ||
}; | ||
@@ -186,7 +179,5 @@ /** | ||
var subscribe = function subscribe(callback) { | ||
const subscribe = callback => { | ||
listeners.add(callback); | ||
return function () { | ||
return listeners.delete(callback); | ||
}; | ||
return () => listeners.delete(callback); | ||
}; | ||
@@ -196,6 +187,3 @@ /** @type {GetLocaleData} */ | ||
var getLocaleData = function getLocaleData() { | ||
var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; | ||
return tannin.data[domain]; | ||
}; | ||
const getLocaleData = (domain = 'default') => tannin.data[domain]; | ||
/** | ||
@@ -207,8 +195,12 @@ * @param {LocaleData} [data] | ||
var doSetLocaleData = function doSetLocaleData(data) { | ||
var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default'; | ||
tannin.data[domain] = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_LOCALE_DATA), tannin.data[domain]), data); // Populate default domain configuration (supported locale date which omits | ||
const doSetLocaleData = (data, domain = 'default') => { | ||
tannin.data[domain] = { ...DEFAULT_LOCALE_DATA, | ||
...tannin.data[domain], | ||
...data | ||
}; // Populate default domain configuration (supported locale date which omits | ||
// a plural forms expression). | ||
tannin.data[domain][''] = _objectSpread(_objectSpread({}, DEFAULT_LOCALE_DATA['']), tannin.data[domain]['']); | ||
tannin.data[domain][''] = { ...DEFAULT_LOCALE_DATA[''], | ||
...tannin.data[domain][''] | ||
}; | ||
}; | ||
@@ -218,3 +210,3 @@ /** @type {SetLocaleData} */ | ||
var setLocaleData = function setLocaleData(data, domain) { | ||
const setLocaleData = (data, domain) => { | ||
doSetLocaleData(data, domain); | ||
@@ -226,3 +218,3 @@ notifyListeners(); | ||
var resetLocaleData = function resetLocaleData(data, domain) { | ||
const resetLocaleData = (data, domain) => { | ||
// Reset all current Tannin locale data. | ||
@@ -251,9 +243,3 @@ tannin.data = {}; // Reset cached plural forms functions cache. | ||
var dcnpgettext = function dcnpgettext() { | ||
var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; | ||
var context = arguments.length > 1 ? arguments[1] : undefined; | ||
var single = arguments.length > 2 ? arguments[2] : undefined; | ||
var plural = arguments.length > 3 ? arguments[3] : undefined; | ||
var number = arguments.length > 4 ? arguments[4] : undefined; | ||
const dcnpgettext = (domain = 'default', context, single, plural, number) => { | ||
if (!tannin.data[domain]) { | ||
@@ -269,11 +255,8 @@ // use `doSetLocaleData` to set silently, without notifying listeners | ||
var getFilterDomain = function getFilterDomain() { | ||
var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; | ||
return domain; | ||
}; | ||
const getFilterDomain = (domain = 'default') => domain; | ||
/** @type {__} */ | ||
var __ = function __(text, domain) { | ||
var translation = dcnpgettext(domain, undefined, text); | ||
const __ = (text, domain) => { | ||
let translation = dcnpgettext(domain, undefined, text); | ||
@@ -307,4 +290,4 @@ if (!hooks) { | ||
var _x = function _x(text, context, domain) { | ||
var translation = dcnpgettext(domain, context, text); | ||
const _x = (text, context, domain) => { | ||
let translation = dcnpgettext(domain, context, text); | ||
@@ -339,4 +322,4 @@ if (!hooks) { | ||
var _n = function _n(single, plural, number, domain) { | ||
var translation = dcnpgettext(domain, undefined, single, plural, number); | ||
const _n = (single, plural, number, domain) => { | ||
let translation = dcnpgettext(domain, undefined, single, plural, number); | ||
@@ -372,4 +355,4 @@ if (!hooks) { | ||
var _nx = function _nx(single, plural, number, context, domain) { | ||
var translation = dcnpgettext(domain, context, single, plural, number); | ||
const _nx = (single, plural, number, context, domain) => { | ||
let translation = dcnpgettext(domain, context, single, plural, number); | ||
@@ -406,3 +389,3 @@ if (!hooks) { | ||
var isRTL = function isRTL() { | ||
const isRTL = () => { | ||
return 'rtl' === _x('ltr', 'text direction'); | ||
@@ -413,7 +396,7 @@ }; | ||
var hasTranslation = function hasTranslation(single, context, domain) { | ||
const hasTranslation = (single, context, domain) => { | ||
var _tannin$data, _tannin$data2; | ||
var key = context ? context + "\x04" + single : single; | ||
var result = !!((_tannin$data = tannin.data) !== null && _tannin$data !== void 0 && (_tannin$data2 = _tannin$data[domain !== null && domain !== void 0 ? domain : 'default']) !== null && _tannin$data2 !== void 0 && _tannin$data2[key]); | ||
const key = context ? context + '\u0004' + single : single; | ||
let result = !!((_tannin$data = tannin.data) !== null && _tannin$data !== void 0 && (_tannin$data2 = _tannin$data[domain !== null && domain !== void 0 ? domain : 'default']) !== null && _tannin$data2 !== void 0 && _tannin$data2[key]); | ||
@@ -452,3 +435,3 @@ if (hooks) { | ||
*/ | ||
var onHookAddedOrRemoved = function onHookAddedOrRemoved(hookName) { | ||
const onHookAddedOrRemoved = hookName => { | ||
if (I18N_HOOK_REGEXP.test(hookName)) { | ||
@@ -464,14 +447,14 @@ notifyListeners(); | ||
return { | ||
getLocaleData: getLocaleData, | ||
setLocaleData: setLocaleData, | ||
resetLocaleData: resetLocaleData, | ||
subscribe: subscribe, | ||
__: __, | ||
_x: _x, | ||
_n: _n, | ||
_nx: _nx, | ||
isRTL: isRTL, | ||
hasTranslation: hasTranslation | ||
getLocaleData, | ||
setLocaleData, | ||
resetLocaleData, | ||
subscribe, | ||
__, | ||
_x, | ||
_n, | ||
_nx, | ||
isRTL, | ||
hasTranslation | ||
}; | ||
}; | ||
//# sourceMappingURL=create-i18n.js.map |
@@ -10,3 +10,3 @@ /** | ||
import { defaultHooks } from '@wordpress/hooks'; | ||
var i18n = createI18n(undefined, undefined, defaultHooks); | ||
const i18n = createI18n(undefined, undefined, defaultHooks); | ||
/** | ||
@@ -37,3 +37,3 @@ * Default, singleton instance of `I18n`. | ||
export var getLocaleData = i18n.getLocaleData.bind(i18n); | ||
export const getLocaleData = i18n.getLocaleData.bind(i18n); | ||
/** | ||
@@ -49,3 +49,3 @@ * Merges locale data into the Tannin instance by domain. Accepts data in a | ||
export var setLocaleData = i18n.setLocaleData.bind(i18n); | ||
export const setLocaleData = i18n.setLocaleData.bind(i18n); | ||
/** | ||
@@ -61,3 +61,3 @@ * Resets all current Tannin instance locale data and sets the specified | ||
export var resetLocaleData = i18n.resetLocaleData.bind(i18n); | ||
export const resetLocaleData = i18n.resetLocaleData.bind(i18n); | ||
/** | ||
@@ -70,3 +70,3 @@ * Subscribes to changes of locale data | ||
export var subscribe = i18n.subscribe.bind(i18n); | ||
export const subscribe = i18n.subscribe.bind(i18n); | ||
/** | ||
@@ -83,3 +83,3 @@ * Retrieve the translation of text. | ||
export var __ = i18n.__.bind(i18n); | ||
export const __ = i18n.__.bind(i18n); | ||
/** | ||
@@ -97,3 +97,3 @@ * Retrieve translated string with gettext context. | ||
export var _x = i18n._x.bind(i18n); | ||
export const _x = i18n._x.bind(i18n); | ||
/** | ||
@@ -114,3 +114,3 @@ * Translates and retrieves the singular or plural form based on the supplied | ||
export var _n = i18n._n.bind(i18n); | ||
export const _n = i18n._n.bind(i18n); | ||
/** | ||
@@ -132,3 +132,3 @@ * Translates and retrieves the singular or plural form based on the supplied | ||
export var _nx = i18n._nx.bind(i18n); | ||
export const _nx = i18n._nx.bind(i18n); | ||
/** | ||
@@ -145,3 +145,3 @@ * Check if current locale is RTL. | ||
export var isRTL = i18n.isRTL.bind(i18n); | ||
export const isRTL = i18n.isRTL.bind(i18n); | ||
/** | ||
@@ -156,3 +156,3 @@ * Check if there is a translation for a given string (in singular form). | ||
export var hasTranslation = i18n.hasTranslation.bind(i18n); | ||
export const hasTranslation = i18n.hasTranslation.bind(i18n); | ||
//# sourceMappingURL=default-i18n.js.map |
@@ -14,3 +14,3 @@ /** | ||
var logErrorOnce = memoize(console.error); // eslint-disable-line no-console | ||
const logErrorOnce = memoize(console.error); // eslint-disable-line no-console | ||
@@ -29,9 +29,5 @@ /** | ||
export function sprintf(format) { | ||
export function sprintf(format, ...args) { | ||
try { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return sprintfjs.sprintf.apply(sprintfjs, [format].concat(args)); | ||
return sprintfjs.sprintf(format, ...args); | ||
} catch (error) { | ||
@@ -38,0 +34,0 @@ logErrorOnce('sprintf error: \n\n' + error.toString()); |
@@ -10,10 +10,8 @@ "use strict"; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _tannin = _interopRequireDefault(require("tannin")); | ||
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; } | ||
/** | ||
* External dependencies | ||
*/ | ||
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) { (0, _defineProperty2.default)(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; } | ||
/** | ||
@@ -29,8 +27,9 @@ * @typedef {Record<string,any>} LocaleData | ||
*/ | ||
var DEFAULT_LOCALE_DATA = { | ||
const DEFAULT_LOCALE_DATA = { | ||
'': { | ||
/** @param {number} n */ | ||
plural_forms: function plural_forms(n) { | ||
plural_forms(n) { | ||
return n === 1 ? 0 : 1; | ||
} | ||
} | ||
@@ -43,3 +42,3 @@ }; | ||
var I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/; | ||
const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/; | ||
/** | ||
@@ -169,3 +168,3 @@ * @typedef {(domain?: string) => LocaleData} GetLocaleData | ||
var createI18n = function createI18n(initialData, initialDomain, hooks) { | ||
const createI18n = (initialData, initialDomain, hooks) => { | ||
/** | ||
@@ -176,9 +175,7 @@ * The underlying instance of Tannin to which exported functions interface. | ||
*/ | ||
var tannin = new _tannin.default({}); | ||
var listeners = new Set(); | ||
const tannin = new _tannin.default({}); | ||
const listeners = new Set(); | ||
var notifyListeners = function notifyListeners() { | ||
listeners.forEach(function (listener) { | ||
return listener(); | ||
}); | ||
const notifyListeners = () => { | ||
listeners.forEach(listener => listener()); | ||
}; | ||
@@ -193,7 +190,5 @@ /** | ||
var subscribe = function subscribe(callback) { | ||
const subscribe = callback => { | ||
listeners.add(callback); | ||
return function () { | ||
return listeners.delete(callback); | ||
}; | ||
return () => listeners.delete(callback); | ||
}; | ||
@@ -203,6 +198,3 @@ /** @type {GetLocaleData} */ | ||
var getLocaleData = function getLocaleData() { | ||
var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; | ||
return tannin.data[domain]; | ||
}; | ||
const getLocaleData = (domain = 'default') => tannin.data[domain]; | ||
/** | ||
@@ -214,8 +206,12 @@ * @param {LocaleData} [data] | ||
var doSetLocaleData = function doSetLocaleData(data) { | ||
var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default'; | ||
tannin.data[domain] = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_LOCALE_DATA), tannin.data[domain]), data); // Populate default domain configuration (supported locale date which omits | ||
const doSetLocaleData = (data, domain = 'default') => { | ||
tannin.data[domain] = { ...DEFAULT_LOCALE_DATA, | ||
...tannin.data[domain], | ||
...data | ||
}; // Populate default domain configuration (supported locale date which omits | ||
// a plural forms expression). | ||
tannin.data[domain][''] = _objectSpread(_objectSpread({}, DEFAULT_LOCALE_DATA['']), tannin.data[domain]['']); | ||
tannin.data[domain][''] = { ...DEFAULT_LOCALE_DATA[''], | ||
...tannin.data[domain][''] | ||
}; | ||
}; | ||
@@ -225,3 +221,3 @@ /** @type {SetLocaleData} */ | ||
var setLocaleData = function setLocaleData(data, domain) { | ||
const setLocaleData = (data, domain) => { | ||
doSetLocaleData(data, domain); | ||
@@ -233,3 +229,3 @@ notifyListeners(); | ||
var resetLocaleData = function resetLocaleData(data, domain) { | ||
const resetLocaleData = (data, domain) => { | ||
// Reset all current Tannin locale data. | ||
@@ -258,9 +254,3 @@ tannin.data = {}; // Reset cached plural forms functions cache. | ||
var dcnpgettext = function dcnpgettext() { | ||
var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; | ||
var context = arguments.length > 1 ? arguments[1] : undefined; | ||
var single = arguments.length > 2 ? arguments[2] : undefined; | ||
var plural = arguments.length > 3 ? arguments[3] : undefined; | ||
var number = arguments.length > 4 ? arguments[4] : undefined; | ||
const dcnpgettext = (domain = 'default', context, single, plural, number) => { | ||
if (!tannin.data[domain]) { | ||
@@ -276,11 +266,8 @@ // use `doSetLocaleData` to set silently, without notifying listeners | ||
var getFilterDomain = function getFilterDomain() { | ||
var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; | ||
return domain; | ||
}; | ||
const getFilterDomain = (domain = 'default') => domain; | ||
/** @type {__} */ | ||
var __ = function __(text, domain) { | ||
var translation = dcnpgettext(domain, undefined, text); | ||
const __ = (text, domain) => { | ||
let translation = dcnpgettext(domain, undefined, text); | ||
@@ -314,4 +301,4 @@ if (!hooks) { | ||
var _x = function _x(text, context, domain) { | ||
var translation = dcnpgettext(domain, context, text); | ||
const _x = (text, context, domain) => { | ||
let translation = dcnpgettext(domain, context, text); | ||
@@ -346,4 +333,4 @@ if (!hooks) { | ||
var _n = function _n(single, plural, number, domain) { | ||
var translation = dcnpgettext(domain, undefined, single, plural, number); | ||
const _n = (single, plural, number, domain) => { | ||
let translation = dcnpgettext(domain, undefined, single, plural, number); | ||
@@ -379,4 +366,4 @@ if (!hooks) { | ||
var _nx = function _nx(single, plural, number, context, domain) { | ||
var translation = dcnpgettext(domain, context, single, plural, number); | ||
const _nx = (single, plural, number, context, domain) => { | ||
let translation = dcnpgettext(domain, context, single, plural, number); | ||
@@ -413,3 +400,3 @@ if (!hooks) { | ||
var isRTL = function isRTL() { | ||
const isRTL = () => { | ||
return 'rtl' === _x('ltr', 'text direction'); | ||
@@ -420,7 +407,7 @@ }; | ||
var hasTranslation = function hasTranslation(single, context, domain) { | ||
const hasTranslation = (single, context, domain) => { | ||
var _tannin$data, _tannin$data2; | ||
var key = context ? context + "\x04" + single : single; | ||
var result = !!((_tannin$data = tannin.data) !== null && _tannin$data !== void 0 && (_tannin$data2 = _tannin$data[domain !== null && domain !== void 0 ? domain : 'default']) !== null && _tannin$data2 !== void 0 && _tannin$data2[key]); | ||
const key = context ? context + '\u0004' + single : single; | ||
let result = !!((_tannin$data = tannin.data) !== null && _tannin$data !== void 0 && (_tannin$data2 = _tannin$data[domain !== null && domain !== void 0 ? domain : 'default']) !== null && _tannin$data2 !== void 0 && _tannin$data2[key]); | ||
@@ -459,3 +446,3 @@ if (hooks) { | ||
*/ | ||
var onHookAddedOrRemoved = function onHookAddedOrRemoved(hookName) { | ||
const onHookAddedOrRemoved = hookName => { | ||
if (I18N_HOOK_REGEXP.test(hookName)) { | ||
@@ -471,12 +458,12 @@ notifyListeners(); | ||
return { | ||
getLocaleData: getLocaleData, | ||
setLocaleData: setLocaleData, | ||
resetLocaleData: resetLocaleData, | ||
subscribe: subscribe, | ||
__: __, | ||
_x: _x, | ||
_n: _n, | ||
_nx: _nx, | ||
isRTL: isRTL, | ||
hasTranslation: hasTranslation | ||
getLocaleData, | ||
setLocaleData, | ||
resetLocaleData, | ||
subscribe, | ||
__, | ||
_x, | ||
_n, | ||
_nx, | ||
isRTL, | ||
hasTranslation | ||
}; | ||
@@ -483,0 +470,0 @@ }; |
@@ -19,3 +19,3 @@ "use strict"; | ||
*/ | ||
var i18n = (0, _createI18n.createI18n)(undefined, undefined, _hooks.defaultHooks); | ||
const i18n = (0, _createI18n.createI18n)(undefined, undefined, _hooks.defaultHooks); | ||
/** | ||
@@ -47,3 +47,3 @@ * Default, singleton instance of `I18n`. | ||
exports.default = _default; | ||
var getLocaleData = i18n.getLocaleData.bind(i18n); | ||
const getLocaleData = i18n.getLocaleData.bind(i18n); | ||
/** | ||
@@ -60,3 +60,3 @@ * Merges locale data into the Tannin instance by domain. Accepts data in a | ||
exports.getLocaleData = getLocaleData; | ||
var setLocaleData = i18n.setLocaleData.bind(i18n); | ||
const setLocaleData = i18n.setLocaleData.bind(i18n); | ||
/** | ||
@@ -73,3 +73,3 @@ * Resets all current Tannin instance locale data and sets the specified | ||
exports.setLocaleData = setLocaleData; | ||
var resetLocaleData = i18n.resetLocaleData.bind(i18n); | ||
const resetLocaleData = i18n.resetLocaleData.bind(i18n); | ||
/** | ||
@@ -83,3 +83,3 @@ * Subscribes to changes of locale data | ||
exports.resetLocaleData = resetLocaleData; | ||
var subscribe = i18n.subscribe.bind(i18n); | ||
const subscribe = i18n.subscribe.bind(i18n); | ||
/** | ||
@@ -98,3 +98,3 @@ * Retrieve the translation of text. | ||
var __ = i18n.__.bind(i18n); | ||
const __ = i18n.__.bind(i18n); | ||
/** | ||
@@ -115,3 +115,3 @@ * Retrieve translated string with gettext context. | ||
var _x = i18n._x.bind(i18n); | ||
const _x = i18n._x.bind(i18n); | ||
/** | ||
@@ -135,3 +135,3 @@ * Translates and retrieves the singular or plural form based on the supplied | ||
var _n = i18n._n.bind(i18n); | ||
const _n = i18n._n.bind(i18n); | ||
/** | ||
@@ -156,3 +156,3 @@ * Translates and retrieves the singular or plural form based on the supplied | ||
var _nx = i18n._nx.bind(i18n); | ||
const _nx = i18n._nx.bind(i18n); | ||
/** | ||
@@ -171,3 +171,3 @@ * Check if current locale is RTL. | ||
exports._nx = _nx; | ||
var isRTL = i18n.isRTL.bind(i18n); | ||
const isRTL = i18n.isRTL.bind(i18n); | ||
/** | ||
@@ -183,4 +183,4 @@ * Check if there is a translation for a given string (in singular form). | ||
exports.isRTL = isRTL; | ||
var hasTranslation = i18n.hasTranslation.bind(i18n); | ||
const hasTranslation = i18n.hasTranslation.bind(i18n); | ||
exports.hasTranslation = hasTranslation; | ||
//# sourceMappingURL=default-i18n.js.map |
@@ -24,3 +24,3 @@ "use strict"; | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _sprintf.sprintf; | ||
@@ -31,3 +31,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n.default; | ||
@@ -38,3 +38,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n.setLocaleData; | ||
@@ -45,3 +45,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n.resetLocaleData; | ||
@@ -52,3 +52,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n.getLocaleData; | ||
@@ -59,3 +59,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n.subscribe; | ||
@@ -66,3 +66,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n.__; | ||
@@ -73,3 +73,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n._x; | ||
@@ -80,3 +80,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n._n; | ||
@@ -87,3 +87,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n._nx; | ||
@@ -94,3 +94,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n.isRTL; | ||
@@ -101,3 +101,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _defaultI18n.hasTranslation; | ||
@@ -117,3 +117,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _createI18n[key]; | ||
@@ -120,0 +120,0 @@ } |
@@ -25,3 +25,3 @@ "use strict"; | ||
*/ | ||
var logErrorOnce = (0, _memize.default)(console.error); // eslint-disable-line no-console | ||
const logErrorOnce = (0, _memize.default)(console.error); // eslint-disable-line no-console | ||
@@ -40,9 +40,5 @@ /** | ||
function sprintf(format) { | ||
function sprintf(format, ...args) { | ||
try { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return _sprintfJs.default.sprintf.apply(_sprintfJs.default, [format].concat(args)); | ||
return _sprintfJs.default.sprintf(format, ...args); | ||
} catch (error) { | ||
@@ -49,0 +45,0 @@ logErrorOnce('sprintf error: \n\n' + error.toString()); |
@@ -5,2 +5,9 @@ <!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. --> | ||
## 4.0.0 (2021-05-14) | ||
### Breaking Changes | ||
- Drop support for Internet Explorer 11 ([#31110](https://github.com/WordPress/gutenberg/pull/31110)). Learn more at https://make.wordpress.org/core/2021/04/22/ie-11-support-phase-out-plan/. | ||
- Increase the minimum Node.js version to v12 matching Long Term Support releases ([#31270](https://github.com/WordPress/gutenberg/pull/31270)). Learn more at https://nodejs.org/en/about/releases/. | ||
## 3.20.0 (2021-04-29) | ||
@@ -7,0 +14,0 @@ |
{ | ||
"name": "@wordpress/i18n", | ||
"version": "3.20.0", | ||
"version": "4.0.0", | ||
"description": "WordPress internationalization (i18n) library.", | ||
@@ -21,2 +21,5 @@ "author": "The WordPress Contributors", | ||
}, | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"main": "build/index.js", | ||
@@ -31,5 +34,5 @@ "module": "build-module/index.js", | ||
"@babel/runtime": "^7.13.10", | ||
"@wordpress/hooks": "^2.12.3", | ||
"@wordpress/hooks": "^3.0.0", | ||
"gettext-parser": "^1.3.1", | ||
"lodash": "^4.17.19", | ||
"lodash": "^4.17.21", | ||
"memize": "^1.1.0", | ||
@@ -42,3 +45,3 @@ "sprintf-js": "^1.1.1", | ||
}, | ||
"gitHead": "4abe97cdbdf5e12bfc95b68c74cd0baa6583fc65" | ||
"gitHead": "0c80fbada8b86cd8e4b4892460caa3a5d0e5f583" | ||
} |
@@ -13,3 +13,3 @@ # Internationalization (i18n) | ||
_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) will add support for these methods. Learn more about it in [Babel docs](https://babeljs.io/docs/en/next/caveats)._ | ||
_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as IE browsers then using [core-js](https://github.com/zloirock/core-js) will add polyfills for these methods._ | ||
@@ -16,0 +16,0 @@ ## Usage |
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
224937
2673
+ Added@wordpress/hooks@3.58.0(transitive)
- Removed@wordpress/hooks@2.12.3(transitive)
Updated@wordpress/hooks@^3.0.0
Updatedlodash@^4.17.21