[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 this["wp"] = this["wp"] || {}; this["wp"]["i18n"] = 2 /******/ (function(modules) { // webpackBootstrap 3 /******/ // The module cache 4 /******/ var installedModules = {}; 5 /******/ 6 /******/ // The require function 7 /******/ function __webpack_require__(moduleId) { 8 /******/ 9 /******/ // Check if module is in cache 10 /******/ if(installedModules[moduleId]) { 11 /******/ return installedModules[moduleId].exports; 12 /******/ } 13 /******/ // Create a new module (and put it into the cache) 14 /******/ var module = installedModules[moduleId] = { 15 /******/ i: moduleId, 16 /******/ l: false, 17 /******/ exports: {} 18 /******/ }; 19 /******/ 20 /******/ // Execute the module function 21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 22 /******/ 23 /******/ // Flag the module as loaded 24 /******/ module.l = true; 25 /******/ 26 /******/ // Return the exports of the module 27 /******/ return module.exports; 28 /******/ } 29 /******/ 30 /******/ 31 /******/ // expose the modules object (__webpack_modules__) 32 /******/ __webpack_require__.m = modules; 33 /******/ 34 /******/ // expose the module cache 35 /******/ __webpack_require__.c = installedModules; 36 /******/ 37 /******/ // define getter function for harmony exports 38 /******/ __webpack_require__.d = function(exports, name, getter) { 39 /******/ if(!__webpack_require__.o(exports, name)) { 40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 41 /******/ } 42 /******/ }; 43 /******/ 44 /******/ // define __esModule on exports 45 /******/ __webpack_require__.r = function(exports) { 46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 48 /******/ } 49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 50 /******/ }; 51 /******/ 52 /******/ // create a fake namespace object 53 /******/ // mode & 1: value is a module id, require it 54 /******/ // mode & 2: merge all properties of value into the ns 55 /******/ // mode & 4: return value when already ns object 56 /******/ // mode & 8|1: behave like require 57 /******/ __webpack_require__.t = function(value, mode) { 58 /******/ if(mode & 1) value = __webpack_require__(value); 59 /******/ if(mode & 8) return value; 60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 61 /******/ var ns = Object.create(null); 62 /******/ __webpack_require__.r(ns); 63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 65 /******/ return ns; 66 /******/ }; 67 /******/ 68 /******/ // getDefaultExport function for compatibility with non-harmony modules 69 /******/ __webpack_require__.n = function(module) { 70 /******/ var getter = module && module.__esModule ? 71 /******/ function getDefault() { return module['default']; } : 72 /******/ function getModuleExports() { return module; }; 73 /******/ __webpack_require__.d(getter, 'a', getter); 74 /******/ return getter; 75 /******/ }; 76 /******/ 77 /******/ // Object.prototype.hasOwnProperty.call 78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 79 /******/ 80 /******/ // __webpack_public_path__ 81 /******/ __webpack_require__.p = ""; 82 /******/ 83 /******/ 84 /******/ // Load entry module and return exports 85 /******/ return __webpack_require__(__webpack_require__.s = 465); 86 /******/ }) 87 /************************************************************************/ 88 /******/ ({ 89 90 /***/ 208: 91 /***/ (function(module, exports, __webpack_require__) { 92 93 var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */ 94 95 !function() { 96 'use strict' 97 98 var re = { 99 not_string: /[^s]/, 100 not_bool: /[^t]/, 101 not_type: /[^T]/, 102 not_primitive: /[^v]/, 103 number: /[diefg]/, 104 numeric_arg: /[bcdiefguxX]/, 105 json: /[j]/, 106 not_json: /[^j]/, 107 text: /^[^\x25]+/, 108 modulo: /^\x25{2}/, 109 placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/, 110 key: /^([a-z_][a-z_\d]*)/i, 111 key_access: /^\.([a-z_][a-z_\d]*)/i, 112 index_access: /^\[(\d+)\]/, 113 sign: /^[+-]/ 114 } 115 116 function sprintf(key) { 117 // `arguments` is not an array, but should be fine for this call 118 return sprintf_format(sprintf_parse(key), arguments) 119 } 120 121 function vsprintf(fmt, argv) { 122 return sprintf.apply(null, [fmt].concat(argv || [])) 123 } 124 125 function sprintf_format(parse_tree, argv) { 126 var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign 127 for (i = 0; i < tree_length; i++) { 128 if (typeof parse_tree[i] === 'string') { 129 output += parse_tree[i] 130 } 131 else if (typeof parse_tree[i] === 'object') { 132 ph = parse_tree[i] // convenience purposes only 133 if (ph.keys) { // keyword argument 134 arg = argv[cursor] 135 for (k = 0; k < ph.keys.length; k++) { 136 if (arg == undefined) { 137 throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k-1])) 138 } 139 arg = arg[ph.keys[k]] 140 } 141 } 142 else if (ph.param_no) { // positional argument (explicit) 143 arg = argv[ph.param_no] 144 } 145 else { // positional argument (implicit) 146 arg = argv[cursor++] 147 } 148 149 if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) { 150 arg = arg() 151 } 152 153 if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) { 154 throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg)) 155 } 156 157 if (re.number.test(ph.type)) { 158 is_positive = arg >= 0 159 } 160 161 switch (ph.type) { 162 case 'b': 163 arg = parseInt(arg, 10).toString(2) 164 break 165 case 'c': 166 arg = String.fromCharCode(parseInt(arg, 10)) 167 break 168 case 'd': 169 case 'i': 170 arg = parseInt(arg, 10) 171 break 172 case 'j': 173 arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0) 174 break 175 case 'e': 176 arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential() 177 break 178 case 'f': 179 arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg) 180 break 181 case 'g': 182 arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg) 183 break 184 case 'o': 185 arg = (parseInt(arg, 10) >>> 0).toString(8) 186 break 187 case 's': 188 arg = String(arg) 189 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 190 break 191 case 't': 192 arg = String(!!arg) 193 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 194 break 195 case 'T': 196 arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase() 197 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 198 break 199 case 'u': 200 arg = parseInt(arg, 10) >>> 0 201 break 202 case 'v': 203 arg = arg.valueOf() 204 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 205 break 206 case 'x': 207 arg = (parseInt(arg, 10) >>> 0).toString(16) 208 break 209 case 'X': 210 arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase() 211 break 212 } 213 if (re.json.test(ph.type)) { 214 output += arg 215 } 216 else { 217 if (re.number.test(ph.type) && (!is_positive || ph.sign)) { 218 sign = is_positive ? '+' : '-' 219 arg = arg.toString().replace(re.sign, '') 220 } 221 else { 222 sign = '' 223 } 224 pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' ' 225 pad_length = ph.width - (sign + arg).length 226 pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : '' 227 output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg) 228 } 229 } 230 } 231 return output 232 } 233 234 var sprintf_cache = Object.create(null) 235 236 function sprintf_parse(fmt) { 237 if (sprintf_cache[fmt]) { 238 return sprintf_cache[fmt] 239 } 240 241 var _fmt = fmt, match, parse_tree = [], arg_names = 0 242 while (_fmt) { 243 if ((match = re.text.exec(_fmt)) !== null) { 244 parse_tree.push(match[0]) 245 } 246 else if ((match = re.modulo.exec(_fmt)) !== null) { 247 parse_tree.push('%') 248 } 249 else if ((match = re.placeholder.exec(_fmt)) !== null) { 250 if (match[2]) { 251 arg_names |= 1 252 var field_list = [], replacement_field = match[2], field_match = [] 253 if ((field_match = re.key.exec(replacement_field)) !== null) { 254 field_list.push(field_match[1]) 255 while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { 256 if ((field_match = re.key_access.exec(replacement_field)) !== null) { 257 field_list.push(field_match[1]) 258 } 259 else if ((field_match = re.index_access.exec(replacement_field)) !== null) { 260 field_list.push(field_match[1]) 261 } 262 else { 263 throw new SyntaxError('[sprintf] failed to parse named argument key') 264 } 265 } 266 } 267 else { 268 throw new SyntaxError('[sprintf] failed to parse named argument key') 269 } 270 match[2] = field_list 271 } 272 else { 273 arg_names |= 2 274 } 275 if (arg_names === 3) { 276 throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported') 277 } 278 279 parse_tree.push( 280 { 281 placeholder: match[0], 282 param_no: match[1], 283 keys: match[2], 284 sign: match[3], 285 pad_char: match[4], 286 align: match[5], 287 width: match[6], 288 precision: match[7], 289 type: match[8] 290 } 291 ) 292 } 293 else { 294 throw new SyntaxError('[sprintf] unexpected placeholder') 295 } 296 _fmt = _fmt.substring(match[0].length) 297 } 298 return sprintf_cache[fmt] = parse_tree 299 } 300 301 /** 302 * export to either browser or node.js 303 */ 304 /* eslint-disable quote-props */ 305 if (true) { 306 exports['sprintf'] = sprintf 307 exports['vsprintf'] = vsprintf 308 } 309 if (typeof window !== 'undefined') { 310 window['sprintf'] = sprintf 311 window['vsprintf'] = vsprintf 312 313 if (true) { 314 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 315 return { 316 'sprintf': sprintf, 317 'vsprintf': vsprintf 318 } 319 }).call(exports, __webpack_require__, exports, module), 320 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) 321 } 322 } 323 /* eslint-enable quote-props */ 324 }(); // eslint-disable-line 325 326 327 /***/ }), 328 329 /***/ 33: 330 /***/ (function(module, exports) { 331 332 (function() { module.exports = window["wp"]["hooks"]; }()); 333 334 /***/ }), 335 336 /***/ 465: 337 /***/ (function(module, __webpack_exports__, __webpack_require__) { 338 339 "use strict"; 340 // ESM COMPAT FLAG 341 __webpack_require__.r(__webpack_exports__); 342 343 // EXPORTS 344 __webpack_require__.d(__webpack_exports__, "sprintf", function() { return /* reexport */ sprintf_sprintf; }); 345 __webpack_require__.d(__webpack_exports__, "createI18n", function() { return /* reexport */ create_i18n_createI18n; }); 346 __webpack_require__.d(__webpack_exports__, "defaultI18n", function() { return /* reexport */ default_i18n; }); 347 __webpack_require__.d(__webpack_exports__, "setLocaleData", function() { return /* reexport */ default_i18n_setLocaleData; }); 348 __webpack_require__.d(__webpack_exports__, "getLocaleData", function() { return /* reexport */ default_i18n_getLocaleData; }); 349 __webpack_require__.d(__webpack_exports__, "subscribe", function() { return /* reexport */ default_i18n_subscribe; }); 350 __webpack_require__.d(__webpack_exports__, "__", function() { return /* reexport */ default_i18n_; }); 351 __webpack_require__.d(__webpack_exports__, "_x", function() { return /* reexport */ default_i18n_x; }); 352 __webpack_require__.d(__webpack_exports__, "_n", function() { return /* reexport */ default_i18n_n; }); 353 __webpack_require__.d(__webpack_exports__, "_nx", function() { return /* reexport */ default_i18n_nx; }); 354 __webpack_require__.d(__webpack_exports__, "isRTL", function() { return /* reexport */ default_i18n_isRTL; }); 355 __webpack_require__.d(__webpack_exports__, "hasTranslation", function() { return /* reexport */ default_i18n_hasTranslation; }); 356 357 // EXTERNAL MODULE: ./node_modules/memize/index.js 358 var memize = __webpack_require__(72); 359 var memize_default = /*#__PURE__*/__webpack_require__.n(memize); 360 361 // EXTERNAL MODULE: ./node_modules/sprintf-js/src/sprintf.js 362 var sprintf = __webpack_require__(208); 363 var sprintf_default = /*#__PURE__*/__webpack_require__.n(sprintf); 364 365 // CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/sprintf.js 366 /** 367 * External dependencies 368 */ 369 370 371 /** 372 * Log to console, once per message; or more precisely, per referentially equal 373 * argument set. Because Jed throws errors, we log these to the console instead 374 * to avoid crashing the application. 375 * 376 * @param {...*} args Arguments to pass to `console.error` 377 */ 378 379 var logErrorOnce = memize_default()(console.error); // eslint-disable-line no-console 380 381 /** 382 * Returns a formatted string. If an error occurs in applying the format, the 383 * original format string is returned. 384 * 385 * @param {string} format The format of the string to generate. 386 * @param {...*} args Arguments to apply to the format. 387 * 388 * @see https://www.npmjs.com/package/sprintf-js 389 * 390 * @return {string} The formatted string. 391 */ 392 393 function sprintf_sprintf(format) { 394 try { 395 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 396 args[_key - 1] = arguments[_key]; 397 } 398 399 return sprintf_default.a.sprintf.apply(sprintf_default.a, [format].concat(args)); 400 } catch (error) { 401 logErrorOnce('sprintf error: \n\n' + error.toString()); 402 return format; 403 } 404 } 405 406 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js 407 var defineProperty = __webpack_require__(5); 408 409 // CONCATENATED MODULE: ./node_modules/@tannin/postfix/index.js 410 var PRECEDENCE, OPENERS, TERMINATORS, PATTERN; 411 412 /** 413 * Operator precedence mapping. 414 * 415 * @type {Object} 416 */ 417 PRECEDENCE = { 418 '(': 9, 419 '!': 8, 420 '*': 7, 421 '/': 7, 422 '%': 7, 423 '+': 6, 424 '-': 6, 425 '<': 5, 426 '<=': 5, 427 '>': 5, 428 '>=': 5, 429 '==': 4, 430 '!=': 4, 431 '&&': 3, 432 '||': 2, 433 '?': 1, 434 '?:': 1, 435 }; 436 437 /** 438 * Characters which signal pair opening, to be terminated by terminators. 439 * 440 * @type {string[]} 441 */ 442 OPENERS = [ '(', '?' ]; 443 444 /** 445 * Characters which signal pair termination, the value an array with the 446 * opener as its first member. The second member is an optional operator 447 * replacement to push to the stack. 448 * 449 * @type {string[]} 450 */ 451 TERMINATORS = { 452 ')': [ '(' ], 453 ':': [ '?', '?:' ], 454 }; 455 456 /** 457 * Pattern matching operators and openers. 458 * 459 * @type {RegExp} 460 */ 461 PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/; 462 463 /** 464 * Given a C expression, returns the equivalent postfix (Reverse Polish) 465 * notation terms as an array. 466 * 467 * If a postfix string is desired, simply `.join( ' ' )` the result. 468 * 469 * @example 470 * 471 * ```js 472 * import postfix from '@tannin/postfix'; 473 * 474 * postfix( 'n > 1' ); 475 * // ⇒ [ 'n', '1', '>' ] 476 * ``` 477 * 478 * @param {string} expression C expression. 479 * 480 * @return {string[]} Postfix terms. 481 */ 482 function postfix( expression ) { 483 var terms = [], 484 stack = [], 485 match, operator, term, element; 486 487 while ( ( match = expression.match( PATTERN ) ) ) { 488 operator = match[ 0 ]; 489 490 // Term is the string preceding the operator match. It may contain 491 // whitespace, and may be empty (if operator is at beginning). 492 term = expression.substr( 0, match.index ).trim(); 493 if ( term ) { 494 terms.push( term ); 495 } 496 497 while ( ( element = stack.pop() ) ) { 498 if ( TERMINATORS[ operator ] ) { 499 if ( TERMINATORS[ operator ][ 0 ] === element ) { 500 // Substitution works here under assumption that because 501 // the assigned operator will no longer be a terminator, it 502 // will be pushed to the stack during the condition below. 503 operator = TERMINATORS[ operator ][ 1 ] || operator; 504 break; 505 } 506 } else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) { 507 // Push to stack if either an opener or when pop reveals an 508 // element of lower precedence. 509 stack.push( element ); 510 break; 511 } 512 513 // For each popped from stack, push to terms. 514 terms.push( element ); 515 } 516 517 if ( ! TERMINATORS[ operator ] ) { 518 stack.push( operator ); 519 } 520 521 // Slice matched fragment from expression to continue match. 522 expression = expression.substr( match.index + operator.length ); 523 } 524 525 // Push remainder of operand, if exists, to terms. 526 expression = expression.trim(); 527 if ( expression ) { 528 terms.push( expression ); 529 } 530 531 // Pop remaining items from stack into terms. 532 return terms.concat( stack.reverse() ); 533 } 534 535 // CONCATENATED MODULE: ./node_modules/@tannin/evaluate/index.js 536 /** 537 * Operator callback functions. 538 * 539 * @type {Object} 540 */ 541 var OPERATORS = { 542 '!': function( a ) { 543 return ! a; 544 }, 545 '*': function( a, b ) { 546 return a * b; 547 }, 548 '/': function( a, b ) { 549 return a / b; 550 }, 551 '%': function( a, b ) { 552 return a % b; 553 }, 554 '+': function( a, b ) { 555 return a + b; 556 }, 557 '-': function( a, b ) { 558 return a - b; 559 }, 560 '<': function( a, b ) { 561 return a < b; 562 }, 563 '<=': function( a, b ) { 564 return a <= b; 565 }, 566 '>': function( a, b ) { 567 return a > b; 568 }, 569 '>=': function( a, b ) { 570 return a >= b; 571 }, 572 '==': function( a, b ) { 573 return a === b; 574 }, 575 '!=': function( a, b ) { 576 return a !== b; 577 }, 578 '&&': function( a, b ) { 579 return a && b; 580 }, 581 '||': function( a, b ) { 582 return a || b; 583 }, 584 '?:': function( a, b, c ) { 585 if ( a ) { 586 throw b; 587 } 588 589 return c; 590 }, 591 }; 592 593 /** 594 * Given an array of postfix terms and operand variables, returns the result of 595 * the postfix evaluation. 596 * 597 * @example 598 * 599 * ```js 600 * import evaluate from '@tannin/evaluate'; 601 * 602 * // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +' 603 * const terms = [ '3', '4', '5', '*', '6', '/', '+' ]; 604 * 605 * evaluate( terms, {} ); 606 * // ⇒ 6.333333333333334 607 * ``` 608 * 609 * @param {string[]} postfix Postfix terms. 610 * @param {Object} variables Operand variables. 611 * 612 * @return {*} Result of evaluation. 613 */ 614 function evaluate_evaluate( postfix, variables ) { 615 var stack = [], 616 i, j, args, getOperatorResult, term, value; 617 618 for ( i = 0; i < postfix.length; i++ ) { 619 term = postfix[ i ]; 620 621 getOperatorResult = OPERATORS[ term ]; 622 if ( getOperatorResult ) { 623 // Pop from stack by number of function arguments. 624 j = getOperatorResult.length; 625 args = Array( j ); 626 while ( j-- ) { 627 args[ j ] = stack.pop(); 628 } 629 630 try { 631 value = getOperatorResult.apply( null, args ); 632 } catch ( earlyReturn ) { 633 return earlyReturn; 634 } 635 } else if ( variables.hasOwnProperty( term ) ) { 636 value = variables[ term ]; 637 } else { 638 value = +term; 639 } 640 641 stack.push( value ); 642 } 643 644 return stack[ 0 ]; 645 } 646 647 // CONCATENATED MODULE: ./node_modules/@tannin/compile/index.js 648 649 650 651 /** 652 * Given a C expression, returns a function which can be called to evaluate its 653 * result. 654 * 655 * @example 656 * 657 * ```js 658 * import compile from '@tannin/compile'; 659 * 660 * const evaluate = compile( 'n > 1' ); 661 * 662 * evaluate( { n: 2 } ); 663 * // ⇒ true 664 * ``` 665 * 666 * @param {string} expression C expression. 667 * 668 * @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator. 669 */ 670 function compile( expression ) { 671 var terms = postfix( expression ); 672 673 return function( variables ) { 674 return evaluate_evaluate( terms, variables ); 675 }; 676 } 677 678 // CONCATENATED MODULE: ./node_modules/@tannin/plural-forms/index.js 679 680 681 /** 682 * Given a C expression, returns a function which, when called with a value, 683 * evaluates the result with the value assumed to be the "n" variable of the 684 * expression. The result will be coerced to its numeric equivalent. 685 * 686 * @param {string} expression C expression. 687 * 688 * @return {Function} Evaluator function. 689 */ 690 function pluralForms( expression ) { 691 var evaluate = compile( expression ); 692 693 return function( n ) { 694 return +evaluate( { n: n } ); 695 }; 696 } 697 698 // CONCATENATED MODULE: ./node_modules/tannin/index.js 699 700 701 /** 702 * Tannin constructor options. 703 * 704 * @typedef {Object} TanninOptions 705 * 706 * @property {string} [contextDelimiter] Joiner in string lookup with context. 707 * @property {Function} [onMissingKey] Callback to invoke when key missing. 708 */ 709 710 /** 711 * Domain metadata. 712 * 713 * @typedef {Object} TanninDomainMetadata 714 * 715 * @property {string} [domain] Domain name. 716 * @property {string} [lang] Language code. 717 * @property {(string|Function)} [plural_forms] Plural forms expression or 718 * function evaluator. 719 */ 720 721 /** 722 * Domain translation pair respectively representing the singular and plural 723 * translation. 724 * 725 * @typedef {[string,string]} TanninTranslation 726 */ 727 728 /** 729 * Locale data domain. The key is used as reference for lookup, the value an 730 * array of two string entries respectively representing the singular and plural 731 * translation. 732 * 733 * @typedef {{[key:string]:TanninDomainMetadata|TanninTranslation,'':TanninDomainMetadata|TanninTranslation}} TanninLocaleDomain 734 */ 735 736 /** 737 * Jed-formatted locale data. 738 * 739 * @see http://messageformat.github.io/Jed/ 740 * 741 * @typedef {{[domain:string]:TanninLocaleDomain}} TanninLocaleData 742 */ 743 744 /** 745 * Default Tannin constructor options. 746 * 747 * @type {TanninOptions} 748 */ 749 var DEFAULT_OPTIONS = { 750 contextDelimiter: '\u0004', 751 onMissingKey: null, 752 }; 753 754 /** 755 * Given a specific locale data's config `plural_forms` value, returns the 756 * expression. 757 * 758 * @example 759 * 760 * ``` 761 * getPluralExpression( 'nplurals=2; plural=(n != 1);' ) === '(n != 1)' 762 * ``` 763 * 764 * @param {string} pf Locale data plural forms. 765 * 766 * @return {string} Plural forms expression. 767 */ 768 function getPluralExpression( pf ) { 769 var parts, i, part; 770 771 parts = pf.split( ';' ); 772 773 for ( i = 0; i < parts.length; i++ ) { 774 part = parts[ i ].trim(); 775 if ( part.indexOf( 'plural=' ) === 0 ) { 776 return part.substr( 7 ); 777 } 778 } 779 } 780 781 /** 782 * Tannin constructor. 783 * 784 * @class 785 * 786 * @param {TanninLocaleData} data Jed-formatted locale data. 787 * @param {TanninOptions} [options] Tannin options. 788 */ 789 function Tannin( data, options ) { 790 var key; 791 792 /** 793 * Jed-formatted locale data. 794 * 795 * @name Tannin#data 796 * @type {TanninLocaleData} 797 */ 798 this.data = data; 799 800 /** 801 * Plural forms function cache, keyed by plural forms string. 802 * 803 * @name Tannin#pluralForms 804 * @type {Object<string,Function>} 805 */ 806 this.pluralForms = {}; 807 808 /** 809 * Effective options for instance, including defaults. 810 * 811 * @name Tannin#options 812 * @type {TanninOptions} 813 */ 814 this.options = {}; 815 816 for ( key in DEFAULT_OPTIONS ) { 817 this.options[ key ] = options !== undefined && key in options 818 ? options[ key ] 819 : DEFAULT_OPTIONS[ key ]; 820 } 821 } 822 823 /** 824 * Returns the plural form index for the given domain and value. 825 * 826 * @param {string} domain Domain on which to calculate plural form. 827 * @param {number} n Value for which plural form is to be calculated. 828 * 829 * @return {number} Plural form index. 830 */ 831 Tannin.prototype.getPluralForm = function( domain, n ) { 832 var getPluralForm = this.pluralForms[ domain ], 833 config, plural, pf; 834 835 if ( ! getPluralForm ) { 836 config = this.data[ domain ][ '' ]; 837 838 pf = ( 839 config[ 'Plural-Forms' ] || 840 config[ 'plural-forms' ] || 841 // Ignore reason: As known, there's no way to document the empty 842 // string property on a key to guarantee this as metadata. 843 // @ts-ignore 844 config.plural_forms 845 ); 846 847 if ( typeof pf !== 'function' ) { 848 plural = getPluralExpression( 849 config[ 'Plural-Forms' ] || 850 config[ 'plural-forms' ] || 851 // Ignore reason: As known, there's no way to document the empty 852 // string property on a key to guarantee this as metadata. 853 // @ts-ignore 854 config.plural_forms 855 ); 856 857 pf = pluralForms( plural ); 858 } 859 860 getPluralForm = this.pluralForms[ domain ] = pf; 861 } 862 863 return getPluralForm( n ); 864 }; 865 866 /** 867 * Translate a string. 868 * 869 * @param {string} domain Translation domain. 870 * @param {string|void} context Context distinguishing terms of the same name. 871 * @param {string} singular Primary key for translation lookup. 872 * @param {string=} plural Fallback value used for non-zero plural 873 * form index. 874 * @param {number=} n Value to use in calculating plural form. 875 * 876 * @return {string} Translated string. 877 */ 878 Tannin.prototype.dcnpgettext = function( domain, context, singular, plural, n ) { 879 var index, key, entry; 880 881 if ( n === undefined ) { 882 // Default to singular. 883 index = 0; 884 } else { 885 // Find index by evaluating plural form for value. 886 index = this.getPluralForm( domain, n ); 887 } 888 889 key = singular; 890 891 // If provided, context is prepended to key with delimiter. 892 if ( context ) { 893 key = context + this.options.contextDelimiter + singular; 894 } 895 896 entry = this.data[ domain ][ key ]; 897 898 // Verify not only that entry exists, but that the intended index is within 899 // range and non-empty. 900 if ( entry && entry[ index ] ) { 901 return entry[ index ]; 902 } 903 904 if ( this.options.onMissingKey ) { 905 this.options.onMissingKey( singular, domain ); 906 } 907 908 // If entry not found, fall back to singular vs. plural with zero index 909 // representing the singular value. 910 return index === 0 ? singular : plural; 911 }; 912 913 // CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/create-i18n.js 914 915 916 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; } 917 918 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; } 919 920 /** 921 * External dependencies 922 */ 923 924 /** 925 * @typedef {Record<string,any>} LocaleData 926 */ 927 928 /** 929 * Default locale data to use for Tannin domain when not otherwise provided. 930 * Assumes an English plural forms expression. 931 * 932 * @type {LocaleData} 933 */ 934 935 var DEFAULT_LOCALE_DATA = { 936 '': { 937 /** @param {number} n */ 938 plural_forms: function plural_forms(n) { 939 return n === 1 ? 0 : 1; 940 } 941 } 942 }; 943 /* 944 * Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`, 945 * `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`. 946 */ 947 948 var I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/; 949 /** 950 * @typedef {(domain?: string) => LocaleData} GetLocaleData 951 * 952 * Returns locale data by domain in a 953 * Jed-formatted JSON object shape. 954 * 955 * @see http://messageformat.github.io/Jed/ 956 */ 957 958 /** 959 * @typedef {(data?: LocaleData, domain?: string) => void} SetLocaleData 960 * 961 * Merges locale data into the Tannin instance by domain. Accepts data in a 962 * Jed-formatted JSON object shape. 963 * 964 * @see http://messageformat.github.io/Jed/ 965 */ 966 967 /** @typedef {() => void} SubscribeCallback */ 968 969 /** @typedef {() => void} UnsubscribeCallback */ 970 971 /** 972 * @typedef {(callback: SubscribeCallback) => UnsubscribeCallback} Subscribe 973 * 974 * Subscribes to changes of locale data 975 */ 976 977 /** 978 * @typedef {(domain?: string) => string} GetFilterDomain 979 * Retrieve the domain to use when calling domain-specific filters. 980 */ 981 982 /** 983 * @typedef {(text: string, domain?: string) => string} __ 984 * 985 * Retrieve the translation of text. 986 * 987 * @see https://developer.wordpress.org/reference/functions/__/ 988 */ 989 990 /** 991 * @typedef {(text: string, context: string, domain?: string) => string} _x 992 * 993 * Retrieve translated string with gettext context. 994 * 995 * @see https://developer.wordpress.org/reference/functions/_x/ 996 */ 997 998 /** 999 * @typedef {(single: string, plural: string, number: number, domain?: string) => string} _n 1000 * 1001 * Translates and retrieves the singular or plural form based on the supplied 1002 * number. 1003 * 1004 * @see https://developer.wordpress.org/reference/functions/_n/ 1005 */ 1006 1007 /** 1008 * @typedef {(single: string, plural: string, number: number, context: string, domain?: string) => string} _nx 1009 * 1010 * Translates and retrieves the singular or plural form based on the supplied 1011 * number, with gettext context. 1012 * 1013 * @see https://developer.wordpress.org/reference/functions/_nx/ 1014 */ 1015 1016 /** 1017 * @typedef {() => boolean} IsRtl 1018 * 1019 * Check if current locale is RTL. 1020 * 1021 * **RTL (Right To Left)** is a locale property indicating that text is written from right to left. 1022 * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common 1023 * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages, 1024 * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`). 1025 */ 1026 1027 /** 1028 * @typedef {(single: string, context?: string, domain?: string) => boolean} HasTranslation 1029 * 1030 * Check if there is a translation for a given string in singular form. 1031 */ 1032 1033 /** @typedef {import('@wordpress/hooks').Hooks} Hooks */ 1034 1035 /** 1036 * An i18n instance 1037 * 1038 * @typedef I18n 1039 * @property {GetLocaleData} getLocaleData Returns locale data by domain in a Jed-formatted JSON object shape. 1040 * @property {SetLocaleData} setLocaleData Merges locale data into the Tannin instance by domain. Accepts data in a 1041 * Jed-formatted JSON object shape. 1042 * @property {Subscribe} subscribe Subscribes to changes of Tannin locale data. 1043 * @property {__} __ Retrieve the translation of text. 1044 * @property {_x} _x Retrieve translated string with gettext context. 1045 * @property {_n} _n Translates and retrieves the singular or plural form based on the supplied 1046 * number. 1047 * @property {_nx} _nx Translates and retrieves the singular or plural form based on the supplied 1048 * number, with gettext context. 1049 * @property {IsRtl} isRTL Check if current locale is RTL. 1050 * @property {HasTranslation} hasTranslation Check if there is a translation for a given string. 1051 */ 1052 1053 /** 1054 * Create an i18n instance 1055 * 1056 * @param {LocaleData} [initialData] Locale data configuration. 1057 * @param {string} [initialDomain] Domain for which configuration applies. 1058 * @param {Hooks} [hooks] Hooks implementation. 1059 * @return {I18n} I18n instance 1060 */ 1061 1062 var create_i18n_createI18n = function createI18n(initialData, initialDomain, hooks) { 1063 /** 1064 * The underlying instance of Tannin to which exported functions interface. 1065 * 1066 * @type {Tannin} 1067 */ 1068 var tannin = new Tannin({}); 1069 var listeners = new Set(); 1070 1071 var notifyListeners = function notifyListeners() { 1072 listeners.forEach(function (listener) { 1073 return listener(); 1074 }); 1075 }; 1076 /** 1077 * Subscribe to changes of locale data. 1078 * 1079 * @param {SubscribeCallback} callback Subscription callback. 1080 * @return {UnsubscribeCallback} Unsubscribe callback. 1081 */ 1082 1083 1084 var subscribe = function subscribe(callback) { 1085 listeners.add(callback); 1086 return function () { 1087 return listeners.delete(callback); 1088 }; 1089 }; 1090 /** @type {GetLocaleData} */ 1091 1092 1093 var getLocaleData = function getLocaleData() { 1094 var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; 1095 return tannin.data[domain]; 1096 }; 1097 /** 1098 * @param {LocaleData} [data] 1099 * @param {string} [domain] 1100 */ 1101 1102 1103 var doSetLocaleData = function doSetLocaleData(data) { 1104 var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default'; 1105 tannin.data[domain] = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_LOCALE_DATA), tannin.data[domain]), data); // Populate default domain configuration (supported locale date which omits 1106 // a plural forms expression). 1107 1108 tannin.data[domain][''] = _objectSpread(_objectSpread({}, DEFAULT_LOCALE_DATA['']), tannin.data[domain]['']); 1109 }; 1110 /** @type {SetLocaleData} */ 1111 1112 1113 var setLocaleData = function setLocaleData(data, domain) { 1114 doSetLocaleData(data, domain); 1115 notifyListeners(); 1116 }; 1117 /** 1118 * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not 1119 * otherwise previously assigned. 1120 * 1121 * @param {string|undefined} domain Domain to retrieve the translated text. 1122 * @param {string|undefined} context Context information for the translators. 1123 * @param {string} single Text to translate if non-plural. Used as 1124 * fallback return value on a caught error. 1125 * @param {string} [plural] The text to be used if the number is 1126 * plural. 1127 * @param {number} [number] The number to compare against to use 1128 * either the singular or plural form. 1129 * 1130 * @return {string} The translated string. 1131 */ 1132 1133 1134 var dcnpgettext = function dcnpgettext() { 1135 var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; 1136 var context = arguments.length > 1 ? arguments[1] : undefined; 1137 var single = arguments.length > 2 ? arguments[2] : undefined; 1138 var plural = arguments.length > 3 ? arguments[3] : undefined; 1139 var number = arguments.length > 4 ? arguments[4] : undefined; 1140 1141 if (!tannin.data[domain]) { 1142 // use `doSetLocaleData` to set silently, without notifying listeners 1143 doSetLocaleData(undefined, domain); 1144 } 1145 1146 return tannin.dcnpgettext(domain, context, single, plural, number); 1147 }; 1148 /** @type {GetFilterDomain} */ 1149 1150 1151 var getFilterDomain = function getFilterDomain() { 1152 var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; 1153 return domain; 1154 }; 1155 /** @type {__} */ 1156 1157 1158 var __ = function __(text, domain) { 1159 var translation = dcnpgettext(domain, undefined, text); 1160 1161 if (!hooks) { 1162 return translation; 1163 } 1164 /** 1165 * Filters text with its translation. 1166 * 1167 * @param {string} translation Translated text. 1168 * @param {string} text Text to translate. 1169 * @param {string} domain Text domain. Unique identifier for retrieving translated strings. 1170 */ 1171 1172 1173 translation = 1174 /** @type {string} */ 1175 1176 /** @type {*} */ 1177 hooks.applyFilters('i18n.gettext', translation, text, domain); 1178 return ( 1179 /** @type {string} */ 1180 1181 /** @type {*} */ 1182 hooks.applyFilters('i18n.gettext_' + getFilterDomain(domain), translation, text, domain) 1183 ); 1184 }; 1185 /** @type {_x} */ 1186 1187 1188 var _x = function _x(text, context, domain) { 1189 var translation = dcnpgettext(domain, context, text); 1190 1191 if (!hooks) { 1192 return translation; 1193 } 1194 /** 1195 * Filters text with its translation based on context information. 1196 * 1197 * @param {string} translation Translated text. 1198 * @param {string} text Text to translate. 1199 * @param {string} context Context information for the translators. 1200 * @param {string} domain Text domain. Unique identifier for retrieving translated strings. 1201 */ 1202 1203 1204 translation = 1205 /** @type {string} */ 1206 1207 /** @type {*} */ 1208 hooks.applyFilters('i18n.gettext_with_context', translation, text, context, domain); 1209 return ( 1210 /** @type {string} */ 1211 1212 /** @type {*} */ 1213 hooks.applyFilters('i18n.gettext_with_context_' + getFilterDomain(domain), translation, text, context, domain) 1214 ); 1215 }; 1216 /** @type {_n} */ 1217 1218 1219 var _n = function _n(single, plural, number, domain) { 1220 var translation = dcnpgettext(domain, undefined, single, plural, number); 1221 1222 if (!hooks) { 1223 return translation; 1224 } 1225 /** 1226 * Filters the singular or plural form of a string. 1227 * 1228 * @param {string} translation Translated text. 1229 * @param {string} single The text to be used if the number is singular. 1230 * @param {string} plural The text to be used if the number is plural. 1231 * @param {string} number The number to compare against to use either the singular or plural form. 1232 * @param {string} domain Text domain. Unique identifier for retrieving translated strings. 1233 */ 1234 1235 1236 translation = 1237 /** @type {string} */ 1238 1239 /** @type {*} */ 1240 hooks.applyFilters('i18n.ngettext', translation, single, plural, number, domain); 1241 return ( 1242 /** @type {string} */ 1243 1244 /** @type {*} */ 1245 hooks.applyFilters('i18n.ngettext_' + getFilterDomain(domain), translation, single, plural, number, domain) 1246 ); 1247 }; 1248 /** @type {_nx} */ 1249 1250 1251 var _nx = function _nx(single, plural, number, context, domain) { 1252 var translation = dcnpgettext(domain, context, single, plural, number); 1253 1254 if (!hooks) { 1255 return translation; 1256 } 1257 /** 1258 * Filters the singular or plural form of a string with gettext context. 1259 * 1260 * @param {string} translation Translated text. 1261 * @param {string} single The text to be used if the number is singular. 1262 * @param {string} plural The text to be used if the number is plural. 1263 * @param {string} number The number to compare against to use either the singular or plural form. 1264 * @param {string} context Context information for the translators. 1265 * @param {string} domain Text domain. Unique identifier for retrieving translated strings. 1266 */ 1267 1268 1269 translation = 1270 /** @type {string} */ 1271 1272 /** @type {*} */ 1273 hooks.applyFilters('i18n.ngettext_with_context', translation, single, plural, number, context, domain); 1274 return ( 1275 /** @type {string} */ 1276 1277 /** @type {*} */ 1278 hooks.applyFilters('i18n.ngettext_with_context_' + getFilterDomain(domain), translation, single, plural, number, context, domain) 1279 ); 1280 }; 1281 /** @type {IsRtl} */ 1282 1283 1284 var isRTL = function isRTL() { 1285 return 'rtl' === _x('ltr', 'text direction'); 1286 }; 1287 /** @type {HasTranslation} */ 1288 1289 1290 var hasTranslation = function hasTranslation(single, context, domain) { 1291 var _tannin$data, _tannin$data2; 1292 1293 var key = context ? context + "\x04" + single : single; 1294 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]); 1295 1296 if (hooks) { 1297 /** 1298 * Filters the presence of a translation in the locale data. 1299 * 1300 * @param {boolean} hasTranslation Whether the translation is present or not.. 1301 * @param {string} single The singular form of the translated text (used as key in locale data) 1302 * @param {string} context Context information for the translators. 1303 * @param {string} domain Text domain. Unique identifier for retrieving translated strings. 1304 */ 1305 result = 1306 /** @type { boolean } */ 1307 1308 /** @type {*} */ 1309 hooks.applyFilters('i18n.has_translation', result, single, context, domain); 1310 result = 1311 /** @type { boolean } */ 1312 1313 /** @type {*} */ 1314 hooks.applyFilters('i18n.has_translation_' + getFilterDomain(domain), result, single, context, domain); 1315 } 1316 1317 return result; 1318 }; 1319 1320 if (initialData) { 1321 setLocaleData(initialData, initialDomain); 1322 } 1323 1324 if (hooks) { 1325 /** 1326 * @param {string} hookName 1327 */ 1328 var onHookAddedOrRemoved = function onHookAddedOrRemoved(hookName) { 1329 if (I18N_HOOK_REGEXP.test(hookName)) { 1330 notifyListeners(); 1331 } 1332 }; 1333 1334 hooks.addAction('hookAdded', 'core/i18n', onHookAddedOrRemoved); 1335 hooks.addAction('hookRemoved', 'core/i18n', onHookAddedOrRemoved); 1336 } 1337 1338 return { 1339 getLocaleData: getLocaleData, 1340 setLocaleData: setLocaleData, 1341 subscribe: subscribe, 1342 __: __, 1343 _x: _x, 1344 _n: _n, 1345 _nx: _nx, 1346 isRTL: isRTL, 1347 hasTranslation: hasTranslation 1348 }; 1349 }; 1350 1351 // EXTERNAL MODULE: external ["wp","hooks"] 1352 var external_wp_hooks_ = __webpack_require__(33); 1353 1354 // CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/default-i18n.js 1355 /** 1356 * Internal dependencies 1357 */ 1358 1359 /** 1360 * WordPress dependencies 1361 */ 1362 1363 1364 var i18n = create_i18n_createI18n(undefined, undefined, external_wp_hooks_["defaultHooks"]); 1365 /** 1366 * Default, singleton instance of `I18n`. 1367 */ 1368 1369 /* harmony default export */ var default_i18n = (i18n); 1370 /* 1371 * Comments in this file are duplicated from ./i18n due to 1372 * https://github.com/WordPress/gutenberg/pull/20318#issuecomment-590837722 1373 */ 1374 1375 /** 1376 * @typedef {import('./create-i18n').LocaleData} LocaleData 1377 * @typedef {import('./create-i18n').SubscribeCallback} SubscribeCallback 1378 * @typedef {import('./create-i18n').UnsubscribeCallback} UnsubscribeCallback 1379 */ 1380 1381 /** 1382 * Returns locale data by domain in a Jed-formatted JSON object shape. 1383 * 1384 * @see http://messageformat.github.io/Jed/ 1385 * 1386 * @param {string} [domain] Domain for which to get the data. 1387 * @return {LocaleData} Locale data. 1388 */ 1389 1390 var default_i18n_getLocaleData = i18n.getLocaleData.bind(i18n); 1391 /** 1392 * Merges locale data into the Tannin instance by domain. Accepts data in a 1393 * Jed-formatted JSON object shape. 1394 * 1395 * @see http://messageformat.github.io/Jed/ 1396 * 1397 * @param {LocaleData} [data] Locale data configuration. 1398 * @param {string} [domain] Domain for which configuration applies. 1399 */ 1400 1401 var default_i18n_setLocaleData = i18n.setLocaleData.bind(i18n); 1402 /** 1403 * Subscribes to changes of locale data 1404 * 1405 * @param {SubscribeCallback} callback Subscription callback 1406 * @return {UnsubscribeCallback} Unsubscribe callback 1407 */ 1408 1409 var default_i18n_subscribe = i18n.subscribe.bind(i18n); 1410 /** 1411 * Retrieve the translation of text. 1412 * 1413 * @see https://developer.wordpress.org/reference/functions/__/ 1414 * 1415 * @param {string} text Text to translate. 1416 * @param {string} [domain] Domain to retrieve the translated text. 1417 * 1418 * @return {string} Translated text. 1419 */ 1420 1421 var default_i18n_ = i18n.__.bind(i18n); 1422 /** 1423 * Retrieve translated string with gettext context. 1424 * 1425 * @see https://developer.wordpress.org/reference/functions/_x/ 1426 * 1427 * @param {string} text Text to translate. 1428 * @param {string} context Context information for the translators. 1429 * @param {string} [domain] Domain to retrieve the translated text. 1430 * 1431 * @return {string} Translated context string without pipe. 1432 */ 1433 1434 var default_i18n_x = i18n._x.bind(i18n); 1435 /** 1436 * Translates and retrieves the singular or plural form based on the supplied 1437 * number. 1438 * 1439 * @see https://developer.wordpress.org/reference/functions/_n/ 1440 * 1441 * @param {string} single The text to be used if the number is singular. 1442 * @param {string} plural The text to be used if the number is plural. 1443 * @param {number} number The number to compare against to use either the 1444 * singular or plural form. 1445 * @param {string} [domain] Domain to retrieve the translated text. 1446 * 1447 * @return {string} The translated singular or plural form. 1448 */ 1449 1450 var default_i18n_n = i18n._n.bind(i18n); 1451 /** 1452 * Translates and retrieves the singular or plural form based on the supplied 1453 * number, with gettext context. 1454 * 1455 * @see https://developer.wordpress.org/reference/functions/_nx/ 1456 * 1457 * @param {string} single The text to be used if the number is singular. 1458 * @param {string} plural The text to be used if the number is plural. 1459 * @param {number} number The number to compare against to use either the 1460 * singular or plural form. 1461 * @param {string} context Context information for the translators. 1462 * @param {string} [domain] Domain to retrieve the translated text. 1463 * 1464 * @return {string} The translated singular or plural form. 1465 */ 1466 1467 var default_i18n_nx = i18n._nx.bind(i18n); 1468 /** 1469 * Check if current locale is RTL. 1470 * 1471 * **RTL (Right To Left)** is a locale property indicating that text is written from right to left. 1472 * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common 1473 * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages, 1474 * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`). 1475 * 1476 * @return {boolean} Whether locale is RTL. 1477 */ 1478 1479 var default_i18n_isRTL = i18n.isRTL.bind(i18n); 1480 /** 1481 * Check if there is a translation for a given string (in singular form). 1482 * 1483 * @param {string} single Singular form of the string to look up. 1484 * @param {string} [context] Context information for the translators. 1485 * @param {string} [domain] Domain to retrieve the translated text. 1486 * @return {boolean} Whether the translation exists or not. 1487 */ 1488 1489 var default_i18n_hasTranslation = i18n.hasTranslation.bind(i18n); 1490 1491 // CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/index.js 1492 1493 1494 1495 1496 1497 /***/ }), 1498 1499 /***/ 5: 1500 /***/ (function(module, __webpack_exports__, __webpack_require__) { 1501 1502 "use strict"; 1503 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); 1504 function _defineProperty(obj, key, value) { 1505 if (key in obj) { 1506 Object.defineProperty(obj, key, { 1507 value: value, 1508 enumerable: true, 1509 configurable: true, 1510 writable: true 1511 }); 1512 } else { 1513 obj[key] = value; 1514 } 1515 1516 return obj; 1517 } 1518 1519 /***/ }), 1520 1521 /***/ 72: 1522 /***/ (function(module, exports, __webpack_require__) { 1523 1524 /** 1525 * Memize options object. 1526 * 1527 * @typedef MemizeOptions 1528 * 1529 * @property {number} [maxSize] Maximum size of the cache. 1530 */ 1531 1532 /** 1533 * Internal cache entry. 1534 * 1535 * @typedef MemizeCacheNode 1536 * 1537 * @property {?MemizeCacheNode|undefined} [prev] Previous node. 1538 * @property {?MemizeCacheNode|undefined} [next] Next node. 1539 * @property {Array<*>} args Function arguments for cache 1540 * entry. 1541 * @property {*} val Function result. 1542 */ 1543 1544 /** 1545 * Properties of the enhanced function for controlling cache. 1546 * 1547 * @typedef MemizeMemoizedFunction 1548 * 1549 * @property {()=>void} clear Clear the cache. 1550 */ 1551 1552 /** 1553 * Accepts a function to be memoized, and returns a new memoized function, with 1554 * optional options. 1555 * 1556 * @template {Function} F 1557 * 1558 * @param {F} fn Function to memoize. 1559 * @param {MemizeOptions} [options] Options object. 1560 * 1561 * @return {F & MemizeMemoizedFunction} Memoized function. 1562 */ 1563 function memize( fn, options ) { 1564 var size = 0; 1565 1566 /** @type {?MemizeCacheNode|undefined} */ 1567 var head; 1568 1569 /** @type {?MemizeCacheNode|undefined} */ 1570 var tail; 1571 1572 options = options || {}; 1573 1574 function memoized( /* ...args */ ) { 1575 var node = head, 1576 len = arguments.length, 1577 args, i; 1578 1579 searchCache: while ( node ) { 1580 // Perform a shallow equality test to confirm that whether the node 1581 // under test is a candidate for the arguments passed. Two arrays 1582 // are shallowly equal if their length matches and each entry is 1583 // strictly equal between the two sets. Avoid abstracting to a 1584 // function which could incur an arguments leaking deoptimization. 1585 1586 // Check whether node arguments match arguments length 1587 if ( node.args.length !== arguments.length ) { 1588 node = node.next; 1589 continue; 1590 } 1591 1592 // Check whether node arguments match arguments values 1593 for ( i = 0; i < len; i++ ) { 1594 if ( node.args[ i ] !== arguments[ i ] ) { 1595 node = node.next; 1596 continue searchCache; 1597 } 1598 } 1599 1600 // At this point we can assume we've found a match 1601 1602 // Surface matched node to head if not already 1603 if ( node !== head ) { 1604 // As tail, shift to previous. Must only shift if not also 1605 // head, since if both head and tail, there is no previous. 1606 if ( node === tail ) { 1607 tail = node.prev; 1608 } 1609 1610 // Adjust siblings to point to each other. If node was tail, 1611 // this also handles new tail's empty `next` assignment. 1612 /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next; 1613 if ( node.next ) { 1614 node.next.prev = node.prev; 1615 } 1616 1617 node.next = head; 1618 node.prev = null; 1619 /** @type {MemizeCacheNode} */ ( head ).prev = node; 1620 head = node; 1621 } 1622 1623 // Return immediately 1624 return node.val; 1625 } 1626 1627 // No cached value found. Continue to insertion phase: 1628 1629 // Create a copy of arguments (avoid leaking deoptimization) 1630 args = new Array( len ); 1631 for ( i = 0; i < len; i++ ) { 1632 args[ i ] = arguments[ i ]; 1633 } 1634 1635 node = { 1636 args: args, 1637 1638 // Generate the result from original function 1639 val: fn.apply( null, args ), 1640 }; 1641 1642 // Don't need to check whether node is already head, since it would 1643 // have been returned above already if it was 1644 1645 // Shift existing head down list 1646 if ( head ) { 1647 head.prev = node; 1648 node.next = head; 1649 } else { 1650 // If no head, follows that there's no tail (at initial or reset) 1651 tail = node; 1652 } 1653 1654 // Trim tail if we're reached max size and are pending cache insertion 1655 if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) { 1656 tail = /** @type {MemizeCacheNode} */ ( tail ).prev; 1657 /** @type {MemizeCacheNode} */ ( tail ).next = null; 1658 } else { 1659 size++; 1660 } 1661 1662 head = node; 1663 1664 return node.val; 1665 } 1666 1667 memoized.clear = function() { 1668 head = null; 1669 tail = null; 1670 size = 0; 1671 }; 1672 1673 if ( false ) {} 1674 1675 // Ignore reason: There's not a clear solution to create an intersection of 1676 // the function with additional properties, where the goal is to retain the 1677 // function signature of the incoming argument and add control properties 1678 // on the return value. 1679 1680 // @ts-ignore 1681 return memoized; 1682 } 1683 1684 module.exports = memize; 1685 1686 1687 /***/ }) 1688 1689 /******/ });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Apr 18 01:00:12 2021 | Cross-referenced by PHPXref 0.7.1 |