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