--- a/wp/wp-includes/js/dist/i18n.js Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-includes/js/dist/i18n.js Wed Sep 21 18:19:35 2022 +0200
@@ -82,12 +82,12 @@
/******/
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 452);
+/******/ return __webpack_require__(__webpack_require__.s = "Vhyj");
/******/ })
/************************************************************************/
/******/ ({
-/***/ 197:
+/***/ "4Z/T":
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */
@@ -326,7 +326,175 @@
/***/ }),
-/***/ 452:
+/***/ "4eJC":
+/***/ (function(module, exports, __webpack_require__) {
+
+/**
+ * Memize options object.
+ *
+ * @typedef MemizeOptions
+ *
+ * @property {number} [maxSize] Maximum size of the cache.
+ */
+
+/**
+ * Internal cache entry.
+ *
+ * @typedef MemizeCacheNode
+ *
+ * @property {?MemizeCacheNode|undefined} [prev] Previous node.
+ * @property {?MemizeCacheNode|undefined} [next] Next node.
+ * @property {Array<*>} args Function arguments for cache
+ * entry.
+ * @property {*} val Function result.
+ */
+
+/**
+ * Properties of the enhanced function for controlling cache.
+ *
+ * @typedef MemizeMemoizedFunction
+ *
+ * @property {()=>void} clear Clear the cache.
+ */
+
+/**
+ * Accepts a function to be memoized, and returns a new memoized function, with
+ * optional options.
+ *
+ * @template {Function} F
+ *
+ * @param {F} fn Function to memoize.
+ * @param {MemizeOptions} [options] Options object.
+ *
+ * @return {F & MemizeMemoizedFunction} Memoized function.
+ */
+function memize( fn, options ) {
+ var size = 0;
+
+ /** @type {?MemizeCacheNode|undefined} */
+ var head;
+
+ /** @type {?MemizeCacheNode|undefined} */
+ var tail;
+
+ options = options || {};
+
+ function memoized( /* ...args */ ) {
+ var node = head,
+ len = arguments.length,
+ args, i;
+
+ searchCache: while ( node ) {
+ // Perform a shallow equality test to confirm that whether the node
+ // under test is a candidate for the arguments passed. Two arrays
+ // are shallowly equal if their length matches and each entry is
+ // strictly equal between the two sets. Avoid abstracting to a
+ // function which could incur an arguments leaking deoptimization.
+
+ // Check whether node arguments match arguments length
+ if ( node.args.length !== arguments.length ) {
+ node = node.next;
+ continue;
+ }
+
+ // Check whether node arguments match arguments values
+ for ( i = 0; i < len; i++ ) {
+ if ( node.args[ i ] !== arguments[ i ] ) {
+ node = node.next;
+ continue searchCache;
+ }
+ }
+
+ // At this point we can assume we've found a match
+
+ // Surface matched node to head if not already
+ if ( node !== head ) {
+ // As tail, shift to previous. Must only shift if not also
+ // head, since if both head and tail, there is no previous.
+ if ( node === tail ) {
+ tail = node.prev;
+ }
+
+ // Adjust siblings to point to each other. If node was tail,
+ // this also handles new tail's empty `next` assignment.
+ /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
+ if ( node.next ) {
+ node.next.prev = node.prev;
+ }
+
+ node.next = head;
+ node.prev = null;
+ /** @type {MemizeCacheNode} */ ( head ).prev = node;
+ head = node;
+ }
+
+ // Return immediately
+ return node.val;
+ }
+
+ // No cached value found. Continue to insertion phase:
+
+ // Create a copy of arguments (avoid leaking deoptimization)
+ args = new Array( len );
+ for ( i = 0; i < len; i++ ) {
+ args[ i ] = arguments[ i ];
+ }
+
+ node = {
+ args: args,
+
+ // Generate the result from original function
+ val: fn.apply( null, args ),
+ };
+
+ // Don't need to check whether node is already head, since it would
+ // have been returned above already if it was
+
+ // Shift existing head down list
+ if ( head ) {
+ head.prev = node;
+ node.next = head;
+ } else {
+ // If no head, follows that there's no tail (at initial or reset)
+ tail = node;
+ }
+
+ // Trim tail if we're reached max size and are pending cache insertion
+ if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
+ tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
+ /** @type {MemizeCacheNode} */ ( tail ).next = null;
+ } else {
+ size++;
+ }
+
+ head = node;
+
+ return node.val;
+ }
+
+ memoized.clear = function() {
+ head = null;
+ tail = null;
+ size = 0;
+ };
+
+ if ( false ) {}
+
+ // Ignore reason: There's not a clear solution to create an intersection of
+ // the function with additional properties, where the goal is to retain the
+ // function signature of the incoming argument and add control properties
+ // on the return value.
+
+ // @ts-ignore
+ return memoized;
+}
+
+module.exports = memize;
+
+
+/***/ }),
+
+/***/ "Vhyj":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -335,20 +503,25 @@
// EXPORTS
__webpack_require__.d(__webpack_exports__, "sprintf", function() { return /* reexport */ sprintf_sprintf; });
-__webpack_require__.d(__webpack_exports__, "createI18n", function() { return /* reexport */ create_i18n_createI18n; });
+__webpack_require__.d(__webpack_exports__, "createI18n", function() { return /* reexport */ createI18n; });
+__webpack_require__.d(__webpack_exports__, "defaultI18n", function() { return /* reexport */ default_i18n; });
__webpack_require__.d(__webpack_exports__, "setLocaleData", function() { return /* reexport */ default_i18n_setLocaleData; });
+__webpack_require__.d(__webpack_exports__, "resetLocaleData", function() { return /* reexport */ default_i18n_resetLocaleData; });
+__webpack_require__.d(__webpack_exports__, "getLocaleData", function() { return /* reexport */ default_i18n_getLocaleData; });
+__webpack_require__.d(__webpack_exports__, "subscribe", function() { return /* reexport */ default_i18n_subscribe; });
__webpack_require__.d(__webpack_exports__, "__", function() { return /* reexport */ default_i18n_; });
__webpack_require__.d(__webpack_exports__, "_x", function() { return /* reexport */ default_i18n_x; });
__webpack_require__.d(__webpack_exports__, "_n", function() { return /* reexport */ default_i18n_n; });
__webpack_require__.d(__webpack_exports__, "_nx", function() { return /* reexport */ default_i18n_nx; });
__webpack_require__.d(__webpack_exports__, "isRTL", function() { return /* reexport */ default_i18n_isRTL; });
+__webpack_require__.d(__webpack_exports__, "hasTranslation", function() { return /* reexport */ default_i18n_hasTranslation; });
// EXTERNAL MODULE: ./node_modules/memize/index.js
-var memize = __webpack_require__(60);
+var memize = __webpack_require__("4eJC");
var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
// EXTERNAL MODULE: ./node_modules/sprintf-js/src/sprintf.js
-var sprintf = __webpack_require__(197);
+var sprintf = __webpack_require__("4Z/T");
var sprintf_default = /*#__PURE__*/__webpack_require__.n(sprintf);
// CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/sprintf.js
@@ -365,7 +538,7 @@
* @param {...*} args Arguments to pass to `console.error`
*/
-var logErrorOnce = memize_default()(console.error); // eslint-disable-line no-console
+const logErrorOnce = memize_default()(console.error); // eslint-disable-line no-console
/**
* Returns a formatted string. If an error occurs in applying the format, the
@@ -374,27 +547,20 @@
* @param {string} format The format of the string to generate.
* @param {...*} args Arguments to apply to the format.
*
- * @see http://www.diveintojavascript.com/projects/javascript-sprintf
+ * @see https://www.npmjs.com/package/sprintf-js
*
* @return {string} The formatted string.
*/
-function sprintf_sprintf(format) {
+function sprintf_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 sprintf_default.a.sprintf.apply(sprintf_default.a, [format].concat(args));
+ return sprintf_default.a.sprintf(format, ...args);
} catch (error) {
logErrorOnce('sprintf error: \n\n' + error.toString());
return format;
}
}
-// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
-var defineProperty = __webpack_require__(5);
-
// CONCATENATED MODULE: ./node_modules/@tannin/postfix/index.js
var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
@@ -900,12 +1066,6 @@
};
// CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/create-i18n.js
-
-
-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) { Object(defineProperty["a" /* 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; }
-
/**
* External dependencies
*/
@@ -921,27 +1081,134 @@
* @type {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;
}
+
}
};
+/*
+ * Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`,
+ * `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`.
+ */
+
+const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
+/**
+ * @typedef {(domain?: string) => LocaleData} GetLocaleData
+ *
+ * Returns locale data by domain in a
+ * Jed-formatted JSON object shape.
+ *
+ * @see http://messageformat.github.io/Jed/
+ */
+
+/**
+ * @typedef {(data?: LocaleData, domain?: string) => void} SetLocaleData
+ *
+ * Merges locale data into the Tannin instance by domain. Accepts data in a
+ * Jed-formatted JSON object shape.
+ *
+ * @see http://messageformat.github.io/Jed/
+ */
+
+/**
+ * @typedef {(data?: LocaleData, domain?: string) => void} ResetLocaleData
+ *
+ * Resets all current Tannin instance locale data and sets the specified
+ * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.
+ *
+ * @see http://messageformat.github.io/Jed/
+ */
+
+/** @typedef {() => void} SubscribeCallback */
+
+/** @typedef {() => void} UnsubscribeCallback */
+
+/**
+ * @typedef {(callback: SubscribeCallback) => UnsubscribeCallback} Subscribe
+ *
+ * Subscribes to changes of locale data
+ */
+
+/**
+ * @typedef {(domain?: string) => string} GetFilterDomain
+ * Retrieve the domain to use when calling domain-specific filters.
+ */
+
+/**
+ * @typedef {(text: string, domain?: string) => string} __
+ *
+ * Retrieve the translation of text.
+ *
+ * @see https://developer.wordpress.org/reference/functions/__/
+ */
+
+/**
+ * @typedef {(text: string, context: string, domain?: string) => string} _x
+ *
+ * Retrieve translated string with gettext context.
+ *
+ * @see https://developer.wordpress.org/reference/functions/_x/
+ */
+
+/**
+ * @typedef {(single: string, plural: string, number: number, domain?: string) => string} _n
+ *
+ * Translates and retrieves the singular or plural form based on the supplied
+ * number.
+ *
+ * @see https://developer.wordpress.org/reference/functions/_n/
+ */
+
+/**
+ * @typedef {(single: string, plural: string, number: number, context: string, domain?: string) => string} _nx
+ *
+ * Translates and retrieves the singular or plural form based on the supplied
+ * number, with gettext context.
+ *
+ * @see https://developer.wordpress.org/reference/functions/_nx/
+ */
+
+/**
+ * @typedef {() => boolean} IsRtl
+ *
+ * Check if current locale is RTL.
+ *
+ * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
+ * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
+ * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
+ * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
+ */
+
+/**
+ * @typedef {(single: string, context?: string, domain?: string) => boolean} HasTranslation
+ *
+ * Check if there is a translation for a given string in singular form.
+ */
+
+/** @typedef {import('@wordpress/hooks').Hooks} Hooks */
+
/**
* An i18n instance
*
- * @typedef {Object} I18n
- * @property {Function} setLocaleData Merges locale data into the Tannin instance by domain. Accepts data in a
- * Jed-formatted JSON object shape.
- * @property {Function} __ Retrieve the translation of text.
- * @property {Function} _x Retrieve translated string with gettext context.
- * @property {Function} _n Translates and retrieves the singular or plural form based on the supplied
- * number.
- * @property {Function} _nx Translates and retrieves the singular or plural form based on the supplied
- * number, with gettext context.
- * @property {Function} isRTL Check if current locale is RTL.
+ * @typedef I18n
+ * @property {GetLocaleData} getLocaleData Returns locale data by domain in a Jed-formatted JSON object shape.
+ * @property {SetLocaleData} setLocaleData Merges locale data into the Tannin instance by domain. Accepts data in a
+ * Jed-formatted JSON object shape.
+ * @property {ResetLocaleData} resetLocaleData Resets all current Tannin instance locale data and sets the specified
+ * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.
+ * @property {Subscribe} subscribe Subscribes to changes of Tannin locale data.
+ * @property {__} __ Retrieve the translation of text.
+ * @property {_x} _x Retrieve translated string with gettext context.
+ * @property {_n} _n Translates and retrieves the singular or plural form based on the supplied
+ * number.
+ * @property {_nx} _nx Translates and retrieves the singular or plural form based on the supplied
+ * number, with gettext context.
+ * @property {IsRtl} isRTL Check if current locale is RTL.
+ * @property {HasTranslation} hasTranslation Check if there is a translation for a given string.
*/
/**
@@ -949,32 +1216,71 @@
*
* @param {LocaleData} [initialData] Locale data configuration.
* @param {string} [initialDomain] Domain for which configuration applies.
+ * @param {Hooks} [hooks] Hooks implementation.
* @return {I18n} I18n instance
*/
-var create_i18n_createI18n = function createI18n(initialData, initialDomain) {
+const createI18n = (initialData, initialDomain, hooks) => {
/**
* The underlying instance of Tannin to which exported functions interface.
*
* @type {Tannin}
*/
- var tannin = new Tannin({});
+ const tannin = new Tannin({});
+ const listeners = new Set();
+
+ const notifyListeners = () => {
+ listeners.forEach(listener => listener());
+ };
/**
- * Merges locale data into the Tannin instance by domain. Accepts data in a
- * Jed-formatted JSON object shape.
+ * Subscribe to changes of locale data.
*
- * @see http://messageformat.github.io/Jed/
- *
- * @param {LocaleData} [data] Locale data configuration.
- * @param {string} [domain] Domain for which configuration applies.
+ * @param {SubscribeCallback} callback Subscription callback.
+ * @return {UnsubscribeCallback} Unsubscribe callback.
+ */
+
+
+ const subscribe = callback => {
+ listeners.add(callback);
+ return () => listeners.delete(callback);
+ };
+ /** @type {GetLocaleData} */
+
+
+ const getLocaleData = (domain = 'default') => tannin.data[domain];
+ /**
+ * @param {LocaleData} [data]
+ * @param {string} [domain]
*/
- var setLocaleData = function setLocaleData(data) {
- var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
- tannin.data[domain] = _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({}, DEFAULT_LOCALE_DATA[''], {}, tannin.data[domain]['']);
+ tannin.data[domain][''] = { ...DEFAULT_LOCALE_DATA[''],
+ ...tannin.data[domain]['']
+ };
+ };
+ /** @type {SetLocaleData} */
+
+
+ const setLocaleData = (data, domain) => {
+ doSetLocaleData(data, domain);
+ notifyListeners();
+ };
+ /** @type {ResetLocaleData} */
+
+
+ const resetLocaleData = (data, domain) => {
+ // Reset all current Tannin locale data.
+ tannin.data = {}; // Reset cached plural forms functions cache.
+
+ tannin.pluralForms = {};
+ setLocaleData(data, domain);
};
/**
* Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not
@@ -993,125 +1299,234 @@
*/
- 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]) {
- setLocaleData(undefined, domain);
+ // use `doSetLocaleData` to set silently, without notifying listeners
+ doSetLocaleData(undefined, domain);
}
return tannin.dcnpgettext(domain, context, single, plural, number);
};
- /**
- * Retrieve the translation of text.
- *
- * @see https://developer.wordpress.org/reference/functions/__/
- *
- * @param {string} text Text to translate.
- * @param {string} [domain] Domain to retrieve the translated text.
- *
- * @return {string} Translated text.
- */
+ /** @type {GetFilterDomain} */
+
+
+ const getFilterDomain = (domain = 'default') => domain;
+ /** @type {__} */
+
+
+ const __ = (text, domain) => {
+ let translation = dcnpgettext(domain, undefined, text);
+
+ if (!hooks) {
+ return translation;
+ }
+ /**
+ * Filters text with its translation.
+ *
+ * @param {string} translation Translated text.
+ * @param {string} text Text to translate.
+ * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
+ */
- var __ = function __(text, domain) {
- return dcnpgettext(domain, undefined, text);
+ translation =
+ /** @type {string} */
+
+ /** @type {*} */
+ hooks.applyFilters('i18n.gettext', translation, text, domain);
+ return (
+ /** @type {string} */
+
+ /** @type {*} */
+ hooks.applyFilters('i18n.gettext_' + getFilterDomain(domain), translation, text, domain)
+ );
};
- /**
- * Retrieve translated string with gettext context.
- *
- * @see https://developer.wordpress.org/reference/functions/_x/
- *
- * @param {string} text Text to translate.
- * @param {string} context Context information for the translators.
- * @param {string} [domain] Domain to retrieve the translated text.
- *
- * @return {string} Translated context string without pipe.
- */
+ /** @type {_x} */
+
+
+ const _x = (text, context, domain) => {
+ let translation = dcnpgettext(domain, context, text);
+
+ if (!hooks) {
+ return translation;
+ }
+ /**
+ * Filters text with its translation based on context information.
+ *
+ * @param {string} translation Translated text.
+ * @param {string} text Text to translate.
+ * @param {string} context Context information for the translators.
+ * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
+ */
+
+
+ translation =
+ /** @type {string} */
+
+ /** @type {*} */
+ hooks.applyFilters('i18n.gettext_with_context', translation, text, context, domain);
+ return (
+ /** @type {string} */
+
+ /** @type {*} */
+ hooks.applyFilters('i18n.gettext_with_context_' + getFilterDomain(domain), translation, text, context, domain)
+ );
+ };
+ /** @type {_n} */
- var _x = function _x(text, context, domain) {
- return dcnpgettext(domain, context, text);
+ const _n = (single, plural, number, domain) => {
+ let translation = dcnpgettext(domain, undefined, single, plural, number);
+
+ if (!hooks) {
+ return translation;
+ }
+ /**
+ * Filters the singular or plural form of a string.
+ *
+ * @param {string} translation Translated text.
+ * @param {string} single The text to be used if the number is singular.
+ * @param {string} plural The text to be used if the number is plural.
+ * @param {string} number The number to compare against to use either the singular or plural form.
+ * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
+ */
+
+
+ translation =
+ /** @type {string} */
+
+ /** @type {*} */
+ hooks.applyFilters('i18n.ngettext', translation, single, plural, number, domain);
+ return (
+ /** @type {string} */
+
+ /** @type {*} */
+ hooks.applyFilters('i18n.ngettext_' + getFilterDomain(domain), translation, single, plural, number, domain)
+ );
};
- /**
- * Translates and retrieves the singular or plural form based on the supplied
- * number.
- *
- * @see https://developer.wordpress.org/reference/functions/_n/
- *
- * @param {string} single The text to be used if the number is singular.
- * @param {string} plural The text to be used if the number is plural.
- * @param {number} number The number to compare against to use either the
- * singular or plural form.
- * @param {string} [domain] Domain to retrieve the translated text.
- *
- * @return {string} The translated singular or plural form.
- */
+ /** @type {_nx} */
+
+
+ const _nx = (single, plural, number, context, domain) => {
+ let translation = dcnpgettext(domain, context, single, plural, number);
+
+ if (!hooks) {
+ return translation;
+ }
+ /**
+ * Filters the singular or plural form of a string with gettext context.
+ *
+ * @param {string} translation Translated text.
+ * @param {string} single The text to be used if the number is singular.
+ * @param {string} plural The text to be used if the number is plural.
+ * @param {string} number The number to compare against to use either the singular or plural form.
+ * @param {string} context Context information for the translators.
+ * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
+ */
- var _n = function _n(single, plural, number, domain) {
- return dcnpgettext(domain, undefined, single, plural, number);
+ translation =
+ /** @type {string} */
+
+ /** @type {*} */
+ hooks.applyFilters('i18n.ngettext_with_context', translation, single, plural, number, context, domain);
+ return (
+ /** @type {string} */
+
+ /** @type {*} */
+ hooks.applyFilters('i18n.ngettext_with_context_' + getFilterDomain(domain), translation, single, plural, number, context, domain)
+ );
};
- /**
- * Translates and retrieves the singular or plural form based on the supplied
- * number, with gettext context.
- *
- * @see https://developer.wordpress.org/reference/functions/_nx/
- *
- * @param {string} single The text to be used if the number is singular.
- * @param {string} plural The text to be used if the number is plural.
- * @param {number} number The number to compare against to use either the
- * singular or plural form.
- * @param {string} context Context information for the translators.
- * @param {string} [domain] Domain to retrieve the translated text.
- *
- * @return {string} The translated singular or plural form.
- */
+ /** @type {IsRtl} */
+
+
+ const isRTL = () => {
+ return 'rtl' === _x('ltr', 'text direction');
+ };
+ /** @type {HasTranslation} */
- var _nx = function _nx(single, plural, number, context, domain) {
- return dcnpgettext(domain, context, single, plural, number);
- };
- /**
- * Check if current locale is RTL.
- *
- * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
- * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
- * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
- * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
- *
- * @return {boolean} Whether locale is RTL.
- */
+ const hasTranslation = (single, context, domain) => {
+ var _tannin$data, _tannin$data2;
+
+ 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]);
+ if (hooks) {
+ /**
+ * Filters the presence of a translation in the locale data.
+ *
+ * @param {boolean} hasTranslation Whether the translation is present or not..
+ * @param {string} single The singular form of the translated text (used as key in locale data)
+ * @param {string} context Context information for the translators.
+ * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
+ */
+ result =
+ /** @type { boolean } */
- var isRTL = function isRTL() {
- return 'rtl' === _x('ltr', 'text direction');
+ /** @type {*} */
+ hooks.applyFilters('i18n.has_translation', result, single, context, domain);
+ result =
+ /** @type { boolean } */
+
+ /** @type {*} */
+ hooks.applyFilters('i18n.has_translation_' + getFilterDomain(domain), result, single, context, domain);
+ }
+
+ return result;
};
if (initialData) {
setLocaleData(initialData, initialDomain);
}
+ if (hooks) {
+ /**
+ * @param {string} hookName
+ */
+ const onHookAddedOrRemoved = hookName => {
+ if (I18N_HOOK_REGEXP.test(hookName)) {
+ notifyListeners();
+ }
+ };
+
+ hooks.addAction('hookAdded', 'core/i18n', onHookAddedOrRemoved);
+ hooks.addAction('hookRemoved', 'core/i18n', onHookAddedOrRemoved);
+ }
+
return {
- setLocaleData: setLocaleData,
- __: __,
- _x: _x,
- _n: _n,
- _nx: _nx,
- isRTL: isRTL
+ getLocaleData,
+ setLocaleData,
+ resetLocaleData,
+ subscribe,
+ __,
+ _x,
+ _n,
+ _nx,
+ isRTL,
+ hasTranslation
};
};
+// EXTERNAL MODULE: external ["wp","hooks"]
+var external_wp_hooks_ = __webpack_require__("g56x");
+
// CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/default-i18n.js
/**
* Internal dependencies
*/
-var i18n = create_i18n_createI18n();
+/**
+ * WordPress dependencies
+ */
+
+
+const i18n = createI18n(undefined, undefined, external_wp_hooks_["defaultHooks"]);
+/**
+ * Default, singleton instance of `I18n`.
+ */
+
+/* harmony default export */ var default_i18n = (i18n);
/*
* Comments in this file are duplicated from ./i18n due to
* https://github.com/WordPress/gutenberg/pull/20318#issuecomment-590837722
@@ -1119,9 +1534,21 @@
/**
* @typedef {import('./create-i18n').LocaleData} LocaleData
+ * @typedef {import('./create-i18n').SubscribeCallback} SubscribeCallback
+ * @typedef {import('./create-i18n').UnsubscribeCallback} UnsubscribeCallback
*/
/**
+ * Returns locale data by domain in a Jed-formatted JSON object shape.
+ *
+ * @see http://messageformat.github.io/Jed/
+ *
+ * @param {string} [domain] Domain for which to get the data.
+ * @return {LocaleData} Locale data.
+ */
+
+const default_i18n_getLocaleData = i18n.getLocaleData.bind(i18n);
+/**
* Merges locale data into the Tannin instance by domain. Accepts data in a
* Jed-formatted JSON object shape.
*
@@ -1131,7 +1558,26 @@
* @param {string} [domain] Domain for which configuration applies.
*/
-var default_i18n_setLocaleData = i18n.setLocaleData.bind(i18n);
+const default_i18n_setLocaleData = i18n.setLocaleData.bind(i18n);
+/**
+ * Resets all current Tannin instance locale data and sets the specified
+ * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.
+ *
+ * @see http://messageformat.github.io/Jed/
+ *
+ * @param {LocaleData} [data] Locale data configuration.
+ * @param {string} [domain] Domain for which configuration applies.
+ */
+
+const default_i18n_resetLocaleData = i18n.resetLocaleData.bind(i18n);
+/**
+ * Subscribes to changes of locale data
+ *
+ * @param {SubscribeCallback} callback Subscription callback
+ * @return {UnsubscribeCallback} Unsubscribe callback
+ */
+
+const default_i18n_subscribe = i18n.subscribe.bind(i18n);
/**
* Retrieve the translation of text.
*
@@ -1143,7 +1589,7 @@
* @return {string} Translated text.
*/
-var default_i18n_ = i18n.__.bind(i18n);
+const default_i18n_ = i18n.__.bind(i18n);
/**
* Retrieve translated string with gettext context.
*
@@ -1156,7 +1602,7 @@
* @return {string} Translated context string without pipe.
*/
-var default_i18n_x = i18n._x.bind(i18n);
+const default_i18n_x = i18n._x.bind(i18n);
/**
* Translates and retrieves the singular or plural form based on the supplied
* number.
@@ -1172,7 +1618,7 @@
* @return {string} The translated singular or plural form.
*/
-var default_i18n_n = i18n._n.bind(i18n);
+const default_i18n_n = i18n._n.bind(i18n);
/**
* Translates and retrieves the singular or plural form based on the supplied
* number, with gettext context.
@@ -1189,7 +1635,7 @@
* @return {string} The translated singular or plural form.
*/
-var default_i18n_nx = i18n._nx.bind(i18n);
+const default_i18n_nx = i18n._nx.bind(i18n);
/**
* Check if current locale is RTL.
*
@@ -1201,7 +1647,17 @@
* @return {boolean} Whether locale is RTL.
*/
-var default_i18n_isRTL = i18n.isRTL.bind(i18n);
+const default_i18n_isRTL = i18n.isRTL.bind(i18n);
+/**
+ * Check if there is a translation for a given string (in singular form).
+ *
+ * @param {string} single Singular form of the string to look up.
+ * @param {string} [context] Context information for the translators.
+ * @param {string} [domain] Domain to retrieve the translated text.
+ * @return {boolean} Whether the translation exists or not.
+ */
+
+const default_i18n_hasTranslation = i18n.hasTranslation.bind(i18n);
// CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/index.js
@@ -1211,193 +1667,10 @@
/***/ }),
-/***/ 5:
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
-function _defineProperty(obj, key, value) {
- if (key in obj) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
-
- return obj;
-}
-
-/***/ }),
-
-/***/ 60:
-/***/ (function(module, exports, __webpack_require__) {
-
-/**
- * Memize options object.
- *
- * @typedef MemizeOptions
- *
- * @property {number} [maxSize] Maximum size of the cache.
- */
-
-/**
- * Internal cache entry.
- *
- * @typedef MemizeCacheNode
- *
- * @property {?MemizeCacheNode|undefined} [prev] Previous node.
- * @property {?MemizeCacheNode|undefined} [next] Next node.
- * @property {Array<*>} args Function arguments for cache
- * entry.
- * @property {*} val Function result.
- */
-
-/**
- * Properties of the enhanced function for controlling cache.
- *
- * @typedef MemizeMemoizedFunction
- *
- * @property {()=>void} clear Clear the cache.
- */
-
-/**
- * Accepts a function to be memoized, and returns a new memoized function, with
- * optional options.
- *
- * @template {Function} F
- *
- * @param {F} fn Function to memoize.
- * @param {MemizeOptions} [options] Options object.
- *
- * @return {F & MemizeMemoizedFunction} Memoized function.
- */
-function memize( fn, options ) {
- var size = 0;
-
- /** @type {?MemizeCacheNode|undefined} */
- var head;
-
- /** @type {?MemizeCacheNode|undefined} */
- var tail;
-
- options = options || {};
-
- function memoized( /* ...args */ ) {
- var node = head,
- len = arguments.length,
- args, i;
-
- searchCache: while ( node ) {
- // Perform a shallow equality test to confirm that whether the node
- // under test is a candidate for the arguments passed. Two arrays
- // are shallowly equal if their length matches and each entry is
- // strictly equal between the two sets. Avoid abstracting to a
- // function which could incur an arguments leaking deoptimization.
-
- // Check whether node arguments match arguments length
- if ( node.args.length !== arguments.length ) {
- node = node.next;
- continue;
- }
+/***/ "g56x":
+/***/ (function(module, exports) {
- // Check whether node arguments match arguments values
- for ( i = 0; i < len; i++ ) {
- if ( node.args[ i ] !== arguments[ i ] ) {
- node = node.next;
- continue searchCache;
- }
- }
-
- // At this point we can assume we've found a match
-
- // Surface matched node to head if not already
- if ( node !== head ) {
- // As tail, shift to previous. Must only shift if not also
- // head, since if both head and tail, there is no previous.
- if ( node === tail ) {
- tail = node.prev;
- }
-
- // Adjust siblings to point to each other. If node was tail,
- // this also handles new tail's empty `next` assignment.
- /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
- if ( node.next ) {
- node.next.prev = node.prev;
- }
-
- node.next = head;
- node.prev = null;
- /** @type {MemizeCacheNode} */ ( head ).prev = node;
- head = node;
- }
-
- // Return immediately
- return node.val;
- }
-
- // No cached value found. Continue to insertion phase:
-
- // Create a copy of arguments (avoid leaking deoptimization)
- args = new Array( len );
- for ( i = 0; i < len; i++ ) {
- args[ i ] = arguments[ i ];
- }
-
- node = {
- args: args,
-
- // Generate the result from original function
- val: fn.apply( null, args ),
- };
-
- // Don't need to check whether node is already head, since it would
- // have been returned above already if it was
-
- // Shift existing head down list
- if ( head ) {
- head.prev = node;
- node.next = head;
- } else {
- // If no head, follows that there's no tail (at initial or reset)
- tail = node;
- }
-
- // Trim tail if we're reached max size and are pending cache insertion
- if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
- tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
- /** @type {MemizeCacheNode} */ ( tail ).next = null;
- } else {
- size++;
- }
-
- head = node;
-
- return node.val;
- }
-
- memoized.clear = function() {
- head = null;
- tail = null;
- size = 0;
- };
-
- if ( false ) {}
-
- // Ignore reason: There's not a clear solution to create an intersection of
- // the function with additional properties, where the goal is to retain the
- // function signature of the incoming argument and add control properties
- // on the return value.
-
- // @ts-ignore
- return memoized;
-}
-
-module.exports = memize;
-
+(function() { module.exports = window["wp"]["hooks"]; }());
/***/ })