| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 "use strict"; 2 var wp; 3 (wp ||= {}).i18n = (() => { 4 var __create = Object.create; 5 var __defProp = Object.defineProperty; 6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 7 var __getOwnPropNames = Object.getOwnPropertyNames; 8 var __getProtoOf = Object.getPrototypeOf; 9 var __hasOwnProp = Object.prototype.hasOwnProperty; 10 var __commonJS = (cb, mod) => function __require() { 11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 12 }; 13 var __export = (target, all) => { 14 for (var name in all) 15 __defProp(target, name, { get: all[name], enumerable: true }); 16 }; 17 var __copyProps = (to, from, except, desc) => { 18 if (from && typeof from === "object" || typeof from === "function") { 19 for (let key of __getOwnPropNames(from)) 20 if (!__hasOwnProp.call(to, key) && key !== except) 21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 22 } 23 return to; 24 }; 25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 26 // If the importer is in node compatibility mode or this is not an ESM 27 // file that has been converted to a CommonJS file using a Babel- 28 // compatible transform (i.e. "__esModule" has not been set), then set 29 // "default" to the CommonJS "module.exports" for node compatibility. 30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 31 mod 32 )); 33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 34 35 // package-external:@wordpress/hooks 36 var require_hooks = __commonJS({ 37 "package-external:@wordpress/hooks"(exports, module) { 38 module.exports = window.wp.hooks; 39 } 40 }); 41 42 // packages/i18n/build-module/index.js 43 var index_exports = {}; 44 __export(index_exports, { 45 __: () => __, 46 _n: () => _n, 47 _nx: () => _nx, 48 _x: () => _x, 49 createI18n: () => createI18n, 50 defaultI18n: () => default_i18n_default, 51 getLocaleData: () => getLocaleData, 52 hasTranslation: () => hasTranslation, 53 isRTL: () => isRTL, 54 resetLocaleData: () => resetLocaleData, 55 setLocaleData: () => setLocaleData, 56 sprintf: () => sprintf2, 57 subscribe: () => subscribe 58 }); 59 60 // node_modules/@tannin/sprintf/src/index.js 61 var PATTERN = /%(((\d+)\$)|(\(([$_a-zA-Z][$_a-zA-Z0-9]*)\)))?[ +0#-]*\d*(\.(\d+|\*))?(ll|[lhqL])?([cduxXefgsp%])/g; 62 function sprintf(string, ...args) { 63 var i = 0; 64 if (Array.isArray(args[0])) { 65 args = /** @type {import('../types').SprintfArgs<T>[]} */ 66 /** @type {unknown} */ 67 args[0]; 68 } 69 return string.replace(PATTERN, function() { 70 var index, name, precision, type, value; 71 index = arguments[3]; 72 name = arguments[5]; 73 precision = arguments[7]; 74 type = arguments[9]; 75 if (type === "%") { 76 return "%"; 77 } 78 if (precision === "*") { 79 precision = args[i]; 80 i++; 81 } 82 if (name === void 0) { 83 if (index === void 0) { 84 index = i + 1; 85 } 86 i++; 87 value = args[index - 1]; 88 } else if (args[0] && typeof args[0] === "object" && args[0].hasOwnProperty(name)) { 89 value = args[0][name]; 90 } 91 if (type === "f") { 92 value = parseFloat(value) || 0; 93 } else if (type === "d") { 94 value = parseInt(value) || 0; 95 } 96 if (precision !== void 0) { 97 if (type === "f") { 98 value = value.toFixed(precision); 99 } else if (type === "s") { 100 value = value.substr(0, precision); 101 } 102 } 103 return value !== void 0 && value !== null ? value : ""; 104 }); 105 } 106 107 // packages/i18n/build-module/sprintf.js 108 function sprintf2(format, ...args) { 109 return sprintf(format, ...args); 110 } 111 112 // node_modules/@tannin/postfix/index.js 113 var PRECEDENCE; 114 var OPENERS; 115 var TERMINATORS; 116 var PATTERN2; 117 PRECEDENCE = { 118 "(": 9, 119 "!": 8, 120 "*": 7, 121 "/": 7, 122 "%": 7, 123 "+": 6, 124 "-": 6, 125 "<": 5, 126 "<=": 5, 127 ">": 5, 128 ">=": 5, 129 "==": 4, 130 "!=": 4, 131 "&&": 3, 132 "||": 2, 133 "?": 1, 134 "?:": 1 135 }; 136 OPENERS = ["(", "?"]; 137 TERMINATORS = { 138 ")": ["("], 139 ":": ["?", "?:"] 140 }; 141 PATTERN2 = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/; 142 function postfix(expression) { 143 var terms = [], stack = [], match, operator, term, element; 144 while (match = expression.match(PATTERN2)) { 145 operator = match[0]; 146 term = expression.substr(0, match.index).trim(); 147 if (term) { 148 terms.push(term); 149 } 150 while (element = stack.pop()) { 151 if (TERMINATORS[operator]) { 152 if (TERMINATORS[operator][0] === element) { 153 operator = TERMINATORS[operator][1] || operator; 154 break; 155 } 156 } else if (OPENERS.indexOf(element) >= 0 || PRECEDENCE[element] < PRECEDENCE[operator]) { 157 stack.push(element); 158 break; 159 } 160 terms.push(element); 161 } 162 if (!TERMINATORS[operator]) { 163 stack.push(operator); 164 } 165 expression = expression.substr(match.index + operator.length); 166 } 167 expression = expression.trim(); 168 if (expression) { 169 terms.push(expression); 170 } 171 return terms.concat(stack.reverse()); 172 } 173 174 // node_modules/@tannin/evaluate/index.js 175 var OPERATORS = { 176 "!": function(a) { 177 return !a; 178 }, 179 "*": function(a, b) { 180 return a * b; 181 }, 182 "/": function(a, b) { 183 return a / b; 184 }, 185 "%": function(a, b) { 186 return a % b; 187 }, 188 "+": function(a, b) { 189 return a + b; 190 }, 191 "-": function(a, b) { 192 return a - b; 193 }, 194 "<": function(a, b) { 195 return a < b; 196 }, 197 "<=": function(a, b) { 198 return a <= b; 199 }, 200 ">": function(a, b) { 201 return a > b; 202 }, 203 ">=": function(a, b) { 204 return a >= b; 205 }, 206 "==": function(a, b) { 207 return a === b; 208 }, 209 "!=": function(a, b) { 210 return a !== b; 211 }, 212 "&&": function(a, b) { 213 return a && b; 214 }, 215 "||": function(a, b) { 216 return a || b; 217 }, 218 "?:": function(a, b, c) { 219 if (a) { 220 throw b; 221 } 222 return c; 223 } 224 }; 225 function evaluate(postfix2, variables) { 226 var stack = [], i, j, args, getOperatorResult, term, value; 227 for (i = 0; i < postfix2.length; i++) { 228 term = postfix2[i]; 229 getOperatorResult = OPERATORS[term]; 230 if (getOperatorResult) { 231 j = getOperatorResult.length; 232 args = Array(j); 233 while (j--) { 234 args[j] = stack.pop(); 235 } 236 try { 237 value = getOperatorResult.apply(null, args); 238 } catch (earlyReturn) { 239 return earlyReturn; 240 } 241 } else if (variables.hasOwnProperty(term)) { 242 value = variables[term]; 243 } else { 244 value = +term; 245 } 246 stack.push(value); 247 } 248 return stack[0]; 249 } 250 251 // node_modules/@tannin/compile/index.js 252 function compile(expression) { 253 var terms = postfix(expression); 254 return function(variables) { 255 return evaluate(terms, variables); 256 }; 257 } 258 259 // node_modules/@tannin/plural-forms/index.js 260 function pluralForms(expression) { 261 var evaluate2 = compile(expression); 262 return function(n) { 263 return +evaluate2({ n }); 264 }; 265 } 266 267 // node_modules/tannin/index.js 268 var DEFAULT_OPTIONS = { 269 contextDelimiter: "", 270 onMissingKey: null 271 }; 272 function getPluralExpression(pf) { 273 var parts, i, part; 274 parts = pf.split(";"); 275 for (i = 0; i < parts.length; i++) { 276 part = parts[i].trim(); 277 if (part.indexOf("plural=") === 0) { 278 return part.substr(7); 279 } 280 } 281 } 282 function Tannin(data, options) { 283 var key; 284 this.data = data; 285 this.pluralForms = {}; 286 this.options = {}; 287 for (key in DEFAULT_OPTIONS) { 288 this.options[key] = options !== void 0 && key in options ? options[key] : DEFAULT_OPTIONS[key]; 289 } 290 } 291 Tannin.prototype.getPluralForm = function(domain, n) { 292 var getPluralForm = this.pluralForms[domain], config, plural, pf; 293 if (!getPluralForm) { 294 config = this.data[domain][""]; 295 pf = config["Plural-Forms"] || config["plural-forms"] || // Ignore reason: As known, there's no way to document the empty 296 // string property on a key to guarantee this as metadata. 297 // @ts-ignore 298 config.plural_forms; 299 if (typeof pf !== "function") { 300 plural = getPluralExpression( 301 config["Plural-Forms"] || config["plural-forms"] || // Ignore reason: As known, there's no way to document the empty 302 // string property on a key to guarantee this as metadata. 303 // @ts-ignore 304 config.plural_forms 305 ); 306 pf = pluralForms(plural); 307 } 308 getPluralForm = this.pluralForms[domain] = pf; 309 } 310 return getPluralForm(n); 311 }; 312 Tannin.prototype.dcnpgettext = function(domain, context, singular, plural, n) { 313 var index, key, entry; 314 if (n === void 0) { 315 index = 0; 316 } else { 317 index = this.getPluralForm(domain, n); 318 } 319 key = singular; 320 if (context) { 321 key = context + this.options.contextDelimiter + singular; 322 } 323 entry = this.data[domain][key]; 324 if (entry && entry[index]) { 325 return entry[index]; 326 } 327 if (this.options.onMissingKey) { 328 this.options.onMissingKey(singular, domain); 329 } 330 return index === 0 ? singular : plural; 331 }; 332 333 // packages/i18n/build-module/create-i18n.js 334 var DEFAULT_LOCALE_DATA = { 335 "": { 336 plural_forms(n) { 337 return n === 1 ? 0 : 1; 338 } 339 } 340 }; 341 var I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/; 342 var createI18n = (initialData, initialDomain, hooks) => { 343 const tannin = new Tannin({}); 344 const listeners = /* @__PURE__ */ new Set(); 345 const notifyListeners = () => { 346 listeners.forEach((listener) => listener()); 347 }; 348 const subscribe2 = (callback) => { 349 listeners.add(callback); 350 return () => listeners.delete(callback); 351 }; 352 const getLocaleData2 = (domain = "default") => tannin.data[domain]; 353 const doSetLocaleData = (data, domain = "default") => { 354 tannin.data[domain] = { 355 ...tannin.data[domain], 356 ...data 357 }; 358 tannin.data[domain][""] = { 359 ...DEFAULT_LOCALE_DATA[""], 360 ...tannin.data[domain]?.[""] 361 }; 362 delete tannin.pluralForms[domain]; 363 }; 364 const setLocaleData2 = (data, domain) => { 365 doSetLocaleData(data, domain); 366 notifyListeners(); 367 }; 368 const addLocaleData = (data, domain = "default") => { 369 tannin.data[domain] = { 370 ...tannin.data[domain], 371 ...data, 372 // Populate default domain configuration (supported locale date which omits 373 // a plural forms expression). 374 "": { 375 ...DEFAULT_LOCALE_DATA[""], 376 ...tannin.data[domain]?.[""], 377 ...data?.[""] 378 } 379 }; 380 delete tannin.pluralForms[domain]; 381 notifyListeners(); 382 }; 383 const resetLocaleData2 = (data, domain) => { 384 tannin.data = {}; 385 tannin.pluralForms = {}; 386 setLocaleData2(data, domain); 387 }; 388 const dcnpgettext = (domain = "default", context, single, plural, number) => { 389 if (!tannin.data[domain]) { 390 doSetLocaleData(void 0, domain); 391 } 392 return tannin.dcnpgettext(domain, context, single, plural, number); 393 }; 394 const getFilterDomain = (domain) => domain || "default"; 395 const __2 = (text, domain) => { 396 let translation = dcnpgettext(domain, void 0, text); 397 if (!hooks) { 398 return translation; 399 } 400 translation = hooks.applyFilters( 401 "i18n.gettext", 402 translation, 403 text, 404 domain 405 ); 406 return hooks.applyFilters( 407 "i18n.gettext_" + getFilterDomain(domain), 408 translation, 409 text, 410 domain 411 ); 412 }; 413 const _x2 = (text, context, domain) => { 414 let translation = dcnpgettext(domain, context, text); 415 if (!hooks) { 416 return translation; 417 } 418 translation = hooks.applyFilters( 419 "i18n.gettext_with_context", 420 translation, 421 text, 422 context, 423 domain 424 ); 425 return hooks.applyFilters( 426 "i18n.gettext_with_context_" + getFilterDomain(domain), 427 translation, 428 text, 429 context, 430 domain 431 ); 432 }; 433 const _n2 = (single, plural, number, domain) => { 434 let translation = dcnpgettext( 435 domain, 436 void 0, 437 single, 438 plural, 439 number 440 ); 441 if (!hooks) { 442 return translation; 443 } 444 translation = hooks.applyFilters( 445 "i18n.ngettext", 446 translation, 447 single, 448 plural, 449 number, 450 domain 451 ); 452 return hooks.applyFilters( 453 "i18n.ngettext_" + getFilterDomain(domain), 454 translation, 455 single, 456 plural, 457 number, 458 domain 459 ); 460 }; 461 const _nx2 = (single, plural, number, context, domain) => { 462 let translation = dcnpgettext( 463 domain, 464 context, 465 single, 466 plural, 467 number 468 ); 469 if (!hooks) { 470 return translation; 471 } 472 translation = hooks.applyFilters( 473 "i18n.ngettext_with_context", 474 translation, 475 single, 476 plural, 477 number, 478 context, 479 domain 480 ); 481 return hooks.applyFilters( 482 "i18n.ngettext_with_context_" + getFilterDomain(domain), 483 translation, 484 single, 485 plural, 486 number, 487 context, 488 domain 489 ); 490 }; 491 const isRTL2 = () => { 492 return "rtl" === _x2("ltr", "text direction"); 493 }; 494 const hasTranslation2 = (single, context, domain) => { 495 const key = context ? context + "" + single : single; 496 let result = !!tannin.data?.[domain ?? "default"]?.[key]; 497 if (hooks) { 498 result = hooks.applyFilters( 499 "i18n.has_translation", 500 result, 501 single, 502 context, 503 domain 504 ); 505 result = hooks.applyFilters( 506 "i18n.has_translation_" + getFilterDomain(domain), 507 result, 508 single, 509 context, 510 domain 511 ); 512 } 513 return result; 514 }; 515 if (initialData) { 516 setLocaleData2(initialData, initialDomain); 517 } 518 if (hooks) { 519 const onHookAddedOrRemoved = (hookName) => { 520 if (I18N_HOOK_REGEXP.test(hookName)) { 521 notifyListeners(); 522 } 523 }; 524 hooks.addAction("hookAdded", "core/i18n", onHookAddedOrRemoved); 525 hooks.addAction("hookRemoved", "core/i18n", onHookAddedOrRemoved); 526 } 527 return { 528 getLocaleData: getLocaleData2, 529 setLocaleData: setLocaleData2, 530 addLocaleData, 531 resetLocaleData: resetLocaleData2, 532 subscribe: subscribe2, 533 __: __2, 534 _x: _x2, 535 _n: _n2, 536 _nx: _nx2, 537 isRTL: isRTL2, 538 hasTranslation: hasTranslation2 539 }; 540 }; 541 542 // packages/i18n/build-module/default-i18n.js 543 var import_hooks = __toESM(require_hooks()); 544 var i18n = createI18n(void 0, void 0, import_hooks.defaultHooks); 545 var default_i18n_default = i18n; 546 var getLocaleData = i18n.getLocaleData.bind(i18n); 547 var setLocaleData = i18n.setLocaleData.bind(i18n); 548 var resetLocaleData = i18n.resetLocaleData.bind(i18n); 549 var subscribe = i18n.subscribe.bind(i18n); 550 var __ = i18n.__.bind(i18n); 551 var _x = i18n._x.bind(i18n); 552 var _n = i18n._n.bind(i18n); 553 var _nx = i18n._nx.bind(i18n); 554 var isRTL = i18n.isRTL.bind(i18n); 555 var hasTranslation = i18n.hasTranslation.bind(i18n); 556 return __toCommonJS(index_exports); 557 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Mon May 25 08:20:05 2026 | Cross-referenced by PHPXref |