Ticket #51498: 51498.patch
File 51498.patch, 14.1 KB (added by , 5 years ago) |
---|
-
src/js/_enqueues/admin/common.js
55 55 * Deprecate all properties on an object. 56 56 * 57 57 * @since 5.5.1 58 * @since 5.6.0 Added the `version` parameter. 58 59 * 59 60 * @param {string} name The name of the object, i.e. commonL10n. 60 61 * @param {object} l10nObject The object to deprecate the properties on. 62 * @param {string} version The version of WordPress that deprecated the property. 61 63 * 62 64 * @return {object} The object with all its properties deprecated. 63 65 */ 64 function deprecateL10nObject( name, l10nObject ) {66 function deprecateL10nObject( name, l10nObject, version ) { 65 67 var deprecatedObject = {}; 66 68 67 69 Object.keys( l10nObject ).forEach( function( key ) { … … 70 72 71 73 if ( 'object' === typeof prop ) { 72 74 Object.defineProperty( deprecatedObject, key, { get: function() { 73 deprecatedProperty( propName, '5.5.0', prop.alternative );75 deprecatedProperty( propName, version, prop.alternative ); 74 76 return prop.func(); 75 77 } } ); 76 78 } else { 77 79 Object.defineProperty( deprecatedObject, key, { get: function() { 78 deprecatedProperty( propName, '5.5.0', 'wp.i18n' );80 deprecatedProperty( propName, version, 'wp.i18n' ); 79 81 return prop; 80 82 } } ); 81 83 } … … 99 101 expandMenu: '' 100 102 }; 101 103 102 window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n );104 window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n, '5.5.0' ); 103 105 104 106 /** 105 107 * Removed in 5.5.0, needed for back-compatibility. … … 111 113 dismiss: '' 112 114 }; 113 115 114 window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n );116 window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n, '5.5.0' ); 115 117 116 118 /** 117 119 * Removed in 5.5.0, needed for back-compatibility. … … 129 131 ariaHide: '' 130 132 }; 131 133 132 window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n );134 window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n, '5.5.0' ); 133 135 134 136 /** 135 137 * Removed in 5.5.0, needed for back-compatibility. … … 148 150 exportError: '' 149 151 }; 150 152 151 window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n );153 window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n, '5.5.0' ); 152 154 153 155 /** 154 156 * Removed in 5.5.0, needed for back-compatibility. … … 160 162 beforeunload: '' 161 163 }; 162 164 163 window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n );165 window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n, '5.5.0' ); 164 166 165 167 /** 166 168 * Removed in 5.5.0, needed for back-compatibility. … … 173 175 broken: '' 174 176 }; 175 177 176 window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n );178 window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n, '5.5.0' ); 177 179 178 180 /** 179 181 * Removed in 5.5.0, needed for back-compatibility. … … 198 200 docTitleCommentsCount: '' 199 201 }; 200 202 201 window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n );203 window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n, '5.5.0' ); 202 204 203 205 /** 204 206 * Removed in 5.5.0, needed for back-compatibility. … … 214 216 termRemoved: '' 215 217 }; 216 218 217 window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n );219 window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n, '5.5.0' ); 218 220 219 221 /** 220 222 * Removed in 5.5.0, needed for back-compatibility. … … 231 233 defaultLabel: '' 232 234 }; 233 235 234 window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n );236 window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n, '5.5.0' ); 235 237 236 238 /** 237 239 * Removed in 5.5.0, needed for back-compatibility. … … 243 245 error: '' 244 246 }; 245 247 246 window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n );248 window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n, '5.5.0' ); 247 249 248 250 /** 249 251 * Removed in 5.5.0, needed for back-compatibility. … … 276 278 permalinkSaved: '' 277 279 }; 278 280 279 window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n );281 window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n, '5.5.0' ); 280 282 281 283 /** 282 284 * Removed in 5.5.0, needed for back-compatibility. … … 292 294 saved: '' 293 295 }; 294 296 295 window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n );297 window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n, '5.5.0' ); 296 298 297 299 /** 298 300 * Removed in 5.5.0, needed for back-compatibility. … … 306 308 ays: '' 307 309 }; 308 310 309 window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n );311 window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n, '5.5.0' ); 310 312 311 313 /** 312 314 * Removed in 5.5.0, needed for back-compatibility. … … 321 323 untitled: '' 322 324 }; 323 325 324 window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n );326 window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n, '5.5.0' ); 325 327 326 328 /** 327 329 * Removed in 5.5.0, needed for back-compatibility. … … 334 336 dateFormat: '' 335 337 }; 336 338 337 window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n );339 window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n, '5.5.0' ); 338 340 339 341 /** 340 342 * Removed in 5.5.0, needed for back-compatibility. … … 349 351 done: '' 350 352 }; 351 353 352 window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n );354 window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n, '5.5.0' ); 353 355 354 356 /** 355 357 * Removed in 3.3.0, needed for back-compatibility. -
src/js/_enqueues/admin/widgets.js
760 760 widgetAdded: '' 761 761 }; 762 762 763 wpWidgets.l10n = window.wp.deprecateL10nObject( 'wpWidgets.l10n', wpWidgets.l10n );763 wpWidgets.l10n = window.wp.deprecateL10nObject( 'wpWidgets.l10n', wpWidgets.l10n, '5.5.0' ); -
src/js/_enqueues/wp/dashboard.js
266 266 'use strict'; 267 267 268 268 var communityEventsData = window.communityEventsData || {}, 269 sprintf = wp.i18n.sprintf, 270 __ = wp.i18n.__, 269 271 app; 270 272 271 273 /** … … 460 462 renderEventsTemplate: function( templateParams, initiatedBy ) { 461 463 var template, 462 464 elementVisibility, 463 l10nPlaceholder = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc.464 465 $toggleButton = $( '.community-events-toggle-location' ), 465 466 $locationMessage = $( '#community-events-location-message' ), 466 467 $results = $( '.community-events-results' ); … … 494 495 * If the API determined the location by geolocating an IP, it will 495 496 * provide events, but not a specific location. 496 497 */ 497 $locationMessage.text( communityEventsData.l10n.attend_event_near_generic);498 $locationMessage.text( __( 'Attend an upcoming event near you.' ) ); 498 499 499 500 if ( templateParams.events.length ) { 500 501 template = wp.template( 'community-events-event-list' ); … … 521 522 } 522 523 523 524 if ( 'user' === initiatedBy ) { 524 wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location.description ), 'assertive' ); 525 wp.a11y.speak( 526 sprintf( 527 /* translators: %s: The name of a city. */ 528 __( 'City updated. Listing events near %s.' ), 529 templateParams.location.description 530 ), 531 'assertive' 532 ); 525 533 } 526 534 527 535 elementVisibility['#community-events-location-message'] = true; … … 531 539 } else if ( templateParams.unknownCity ) { 532 540 template = wp.template( 'community-events-could-not-locate' ); 533 541 $( '.community-events-could-not-locate' ).html( template( templateParams ) ); 534 wp.a11y.speak( communityEventsData.l10n.could_not_locate_city.replace( l10nPlaceholder, templateParams.unknownCity ) ); 542 wp.a11y.speak( 543 sprintf( 544 /* 545 * These specific examples were chosen to highlight the fact that a 546 * state is not needed, even for cities whose name is not unique. 547 * It would be too cumbersome to include that in the instructions 548 * to the user, so it's left as an implication. 549 */ 550 /* 551 * translators: %s is the name of the city we couldn't locate. 552 * Replace the examples with cities related to your locale. Test that 553 * they match the expected location and have upcoming events before 554 * including them. If no cities related to your locale have events, 555 * then use cities related to your locale that would be recognizable 556 * to most users. Use only the city name itself, without any region 557 * or country. Use the endonym (native locale name) instead of the 558 * English name if possible. 559 */ 560 __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ), 561 templateParams.unknownCity 562 ) 563 ); 535 564 536 565 elementVisibility['.community-events-errors'] = true; 537 566 elementVisibility['.community-events-could-not-locate'] = true; … … 543 572 * Showing error messages for an event that user isn't aware of 544 573 * could be confusing or unnecessarily distracting. 545 574 */ 546 wp.a11y.speak( communityEventsData.l10n.error_occurred_please_try_again);575 wp.a11y.speak( __( 'An error occurred. Please try again.' ) ); 547 576 548 577 elementVisibility['.community-events-errors'] = true; 549 578 elementVisibility['.community-events-error-occurred'] = true; 550 579 } else { 551 $locationMessage.text( communityEventsData.l10n.enter_closest_city);580 $locationMessage.text( __( 'Enter your closest city to find nearby events.' ) ); 552 581 553 582 elementVisibility['#community-events-location-message'] = true; 554 583 elementVisibility['.community-events-toggle-location'] = true; … … 591 620 }); 592 621 } 593 622 }); 623 624 /** 625 * Removed in 5.6.0, needed for back-compatibility. 626 * 627 * @since 4.9.0 628 * @deprecated 5.6.0 629 * 630 * @type {object} 631 */ 632 window.communityEventsData = window.communityEventsData || {}; 633 window.communityEventsData.l10n = window.communityEventsData.l10n || { 634 enter_closest_city: '', 635 error_occurred_please_try_again: '', 636 attend_event_near_generic: '', 637 could_not_locate_city: '', 638 city_updated: '' 639 }; 640 641 window.communityEventsData.l10n = window.wp.deprecateL10nObject( 'communityEventsData.l10n', window.communityEventsData.l10n, '5.6.0' ); -
src/js/_enqueues/wp/theme-plugin-editor.js
1023 1023 } 1024 1024 }; 1025 1025 1026 wp.themePluginEditor.l10n = window.wp.deprecateL10nObject( 'wp.themePluginEditor.l10n', wp.themePluginEditor.l10n );1026 wp.themePluginEditor.l10n = window.wp.deprecateL10nObject( 'wp.themePluginEditor.l10n', wp.themePluginEditor.l10n, '5.5.0' ); -
src/js/_enqueues/wp/updates.js
115 115 autoUpdatesError: '' 116 116 }; 117 117 118 wp.updates.l10n = window.wp.deprecateL10nObject( 'wp.updates.l10n', wp.updates.l10n );118 wp.updates.l10n = window.wp.deprecateL10nObject( 'wp.updates.l10n', wp.updates.l10n, '5.5.0' ); 119 119 120 120 /** 121 121 * User nonce for ajax calls. -
src/wp-includes/script-loader.php
1309 1309 $scripts->set_translations( 'wp-color-picker' ); 1310 1310 1311 1311 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 ); 1312 $scripts->set_translations( 'dashboard' ); 1312 1313 1313 1314 $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); 1314 1315 … … 1755 1756 array( 1756 1757 'nonce' => wp_create_nonce( 'community_events' ), 1757 1758 'cache' => $events_client->get_cached_events(), 1758 1759 'l10n' => array(1760 'enter_closest_city' => __( 'Enter your closest city to find nearby events.' ),1761 'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ),1762 'attend_event_near_generic' => __( 'Attend an upcoming event near you.' ),1763 1764 /*1765 * These specific examples were chosen to highlight the fact that a1766 * state is not needed, even for cities whose name is not unique.1767 * It would be too cumbersome to include that in the instructions1768 * to the user, so it's left as an implication.1769 */1770 /*1771 * translators: %s is the name of the city we couldn't locate.1772 * Replace the examples with cities related to your locale. Test that1773 * they match the expected location and have upcoming events before1774 * including them. If no cities related to your locale have events,1775 * then use cities related to your locale that would be recognizable1776 * to most users. Use only the city name itself, without any region1777 * or country. Use the endonym (native locale name) instead of the1778 * English name if possible.1779 */1780 'could_not_locate_city' => __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),1781 1782 // This one is only used with wp.a11y.speak(), so it can/should be more brief.1783 /* translators: %s: The name of a city. */1784 'city_updated' => __( 'City updated. Listing events near %s.' ),1785 ),1786 1759 ) 1787 1760 ); 1788 1761 }