I18N: Use `wp.i18n` for translatable strings in `wp-admin/js/dashboard.js`.
* Deprecate the `l10n` property on `communityEventsData`. * Introduce `version` parameter for `deprecateL10nObject` and backfill the version for deprecated objects in 5.5.0. * Add a noop version of `deprecateL10nObject` for QUnit testing. Fixes #51498. Built from https://develop.svn.wordpress.org/trunk@49151 git-svn-id: http://core.svn.wordpress.org/trunk@48913 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8ce5e19a65
commit
c6f7e0f155
|
@ -55,13 +55,15 @@ function deprecatedProperty( propName, version, replacement ) {
|
|||
* Deprecate all properties on an object.
|
||||
*
|
||||
* @since 5.5.1
|
||||
* @since 5.6.0 Added the `version` parameter.
|
||||
*
|
||||
* @param {string} name The name of the object, i.e. commonL10n.
|
||||
* @param {object} l10nObject The object to deprecate the properties on.
|
||||
* @param {string} version The version of WordPress that deprecated the property.
|
||||
*
|
||||
* @return {object} The object with all its properties deprecated.
|
||||
*/
|
||||
function deprecateL10nObject( name, l10nObject ) {
|
||||
function deprecateL10nObject( name, l10nObject, version ) {
|
||||
var deprecatedObject = {};
|
||||
|
||||
Object.keys( l10nObject ).forEach( function( key ) {
|
||||
|
@ -70,12 +72,12 @@ function deprecateL10nObject( name, l10nObject ) {
|
|||
|
||||
if ( 'object' === typeof prop ) {
|
||||
Object.defineProperty( deprecatedObject, key, { get: function() {
|
||||
deprecatedProperty( propName, '5.5.0', prop.alternative );
|
||||
deprecatedProperty( propName, version, prop.alternative );
|
||||
return prop.func();
|
||||
} } );
|
||||
} else {
|
||||
Object.defineProperty( deprecatedObject, key, { get: function() {
|
||||
deprecatedProperty( propName, '5.5.0', 'wp.i18n' );
|
||||
deprecatedProperty( propName, version, 'wp.i18n' );
|
||||
return prop;
|
||||
} } );
|
||||
}
|
||||
|
@ -99,7 +101,7 @@ window.commonL10n = window.commonL10n || {
|
|||
expandMenu: ''
|
||||
};
|
||||
|
||||
window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n );
|
||||
window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -111,7 +113,7 @@ window.wpPointerL10n = window.wpPointerL10n || {
|
|||
dismiss: ''
|
||||
};
|
||||
|
||||
window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n );
|
||||
window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -129,7 +131,7 @@ window.userProfileL10n = window.userProfileL10n || {
|
|||
ariaHide: ''
|
||||
};
|
||||
|
||||
window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n );
|
||||
window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -148,7 +150,7 @@ window.privacyToolsL10n = window.privacyToolsL10n || {
|
|||
exportError: ''
|
||||
};
|
||||
|
||||
window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n );
|
||||
window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -160,7 +162,7 @@ window.authcheckL10n = {
|
|||
beforeunload: ''
|
||||
};
|
||||
|
||||
window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n );
|
||||
window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -173,7 +175,7 @@ window.tagsl10n = {
|
|||
broken: ''
|
||||
};
|
||||
|
||||
window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n );
|
||||
window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -198,7 +200,7 @@ window.adminCommentsL10n = window.adminCommentsL10n || {
|
|||
docTitleCommentsCount: ''
|
||||
};
|
||||
|
||||
window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n );
|
||||
window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -214,7 +216,7 @@ window.tagsSuggestL10n = window.tagsSuggestL10n || {
|
|||
termRemoved: ''
|
||||
};
|
||||
|
||||
window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n );
|
||||
window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -231,7 +233,7 @@ window.wpColorPickerL10n = window.wpColorPickerL10n || {
|
|||
defaultLabel: ''
|
||||
};
|
||||
|
||||
window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n );
|
||||
window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -243,7 +245,7 @@ window.attachMediaBoxL10n = window.attachMediaBoxL10n || {
|
|||
error: ''
|
||||
};
|
||||
|
||||
window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n );
|
||||
window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -276,7 +278,7 @@ window.postL10n = window.postL10n || {
|
|||
permalinkSaved: ''
|
||||
};
|
||||
|
||||
window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n );
|
||||
window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -292,7 +294,7 @@ window.inlineEditL10n = window.inlineEditL10n || {
|
|||
saved: ''
|
||||
};
|
||||
|
||||
window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n );
|
||||
window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -306,7 +308,7 @@ window.plugininstallL10n = window.plugininstallL10n || {
|
|||
ays: ''
|
||||
};
|
||||
|
||||
window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n );
|
||||
window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -321,7 +323,7 @@ window.navMenuL10n = window.navMenuL10n || {
|
|||
untitled: ''
|
||||
};
|
||||
|
||||
window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n );
|
||||
window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -334,7 +336,7 @@ window.commentL10n = window.commentL10n || {
|
|||
dateFormat: ''
|
||||
};
|
||||
|
||||
window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n );
|
||||
window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 5.5.0, needed for back-compatibility.
|
||||
|
@ -349,7 +351,7 @@ window.setPostThumbnailL10n = window.setPostThumbnailL10n || {
|
|||
done: ''
|
||||
};
|
||||
|
||||
window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n );
|
||||
window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* Removed in 3.3.0, needed for back-compatibility.
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5,6 +5,7 @@
|
|||
/* global pagenow, ajaxurl, postboxes, wpActiveEditor:true, ajaxWidgets */
|
||||
/* global ajaxPopulateWidgets, quickPressLoad, */
|
||||
window.wp = window.wp || {};
|
||||
window.communityEventsData = window.communityEventsData || {};
|
||||
|
||||
/**
|
||||
* Initializes the dashboard widget functionality.
|
||||
|
@ -265,7 +266,7 @@ jQuery(document).ready( function($) {
|
|||
jQuery( function( $ ) {
|
||||
'use strict';
|
||||
|
||||
var communityEventsData = window.communityEventsData || {},
|
||||
var communityEventsData = window.communityEventsData,
|
||||
dateI18n = wp.date.dateI18n,
|
||||
format = wp.date.format,
|
||||
sprintf = wp.i18n.sprintf,
|
||||
|
@ -466,7 +467,6 @@ jQuery( function( $ ) {
|
|||
renderEventsTemplate: function( templateParams, initiatedBy ) {
|
||||
var template,
|
||||
elementVisibility,
|
||||
l10nPlaceholder = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc.
|
||||
$toggleButton = $( '.community-events-toggle-location' ),
|
||||
$locationMessage = $( '#community-events-location-message' ),
|
||||
$results = $( '.community-events-results' );
|
||||
|
@ -505,7 +505,7 @@ jQuery( function( $ ) {
|
|||
* If the API determined the location by geolocating an IP, it will
|
||||
* provide events, but not a specific location.
|
||||
*/
|
||||
$locationMessage.text( communityEventsData.l10n.attend_event_near_generic );
|
||||
$locationMessage.text( __( 'Attend an upcoming event near you.' ) );
|
||||
|
||||
if ( templateParams.events.length ) {
|
||||
template = wp.template( 'community-events-event-list' );
|
||||
|
@ -532,7 +532,14 @@ jQuery( function( $ ) {
|
|||
}
|
||||
|
||||
if ( 'user' === initiatedBy ) {
|
||||
wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location.description ), 'assertive' );
|
||||
wp.a11y.speak(
|
||||
sprintf(
|
||||
/* translators: %s: The name of a city. */
|
||||
__( 'City updated. Listing events near %s.' ),
|
||||
templateParams.location.description
|
||||
),
|
||||
'assertive'
|
||||
);
|
||||
}
|
||||
|
||||
elementVisibility['#community-events-location-message'] = true;
|
||||
|
@ -542,7 +549,28 @@ jQuery( function( $ ) {
|
|||
} else if ( templateParams.unknownCity ) {
|
||||
template = wp.template( 'community-events-could-not-locate' );
|
||||
$( '.community-events-could-not-locate' ).html( template( templateParams ) );
|
||||
wp.a11y.speak( communityEventsData.l10n.could_not_locate_city.replace( l10nPlaceholder, templateParams.unknownCity ) );
|
||||
wp.a11y.speak(
|
||||
sprintf(
|
||||
/*
|
||||
* These specific examples were chosen to highlight the fact that a
|
||||
* state is not needed, even for cities whose name is not unique.
|
||||
* It would be too cumbersome to include that in the instructions
|
||||
* to the user, so it's left as an implication.
|
||||
*/
|
||||
/*
|
||||
* translators: %s is the name of the city we couldn't locate.
|
||||
* Replace the examples with cities related to your locale. Test that
|
||||
* they match the expected location and have upcoming events before
|
||||
* including them. If no cities related to your locale have events,
|
||||
* then use cities related to your locale that would be recognizable
|
||||
* to most users. Use only the city name itself, without any region
|
||||
* or country. Use the endonym (native locale name) instead of the
|
||||
* English name if possible.
|
||||
*/
|
||||
__( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
|
||||
templateParams.unknownCity
|
||||
)
|
||||
);
|
||||
|
||||
elementVisibility['.community-events-errors'] = true;
|
||||
elementVisibility['.community-events-could-not-locate'] = true;
|
||||
|
@ -554,12 +582,12 @@ jQuery( function( $ ) {
|
|||
* Showing error messages for an event that user isn't aware of
|
||||
* could be confusing or unnecessarily distracting.
|
||||
*/
|
||||
wp.a11y.speak( communityEventsData.l10n.error_occurred_please_try_again );
|
||||
wp.a11y.speak( __( 'An error occurred. Please try again.' ) );
|
||||
|
||||
elementVisibility['.community-events-errors'] = true;
|
||||
elementVisibility['.community-events-error-occurred'] = true;
|
||||
} else {
|
||||
$locationMessage.text( communityEventsData.l10n.enter_closest_city );
|
||||
$locationMessage.text( __( 'Enter your closest city to find nearby events.' ) );
|
||||
|
||||
elementVisibility['#community-events-location-message'] = true;
|
||||
elementVisibility['.community-events-toggle-location'] = true;
|
||||
|
@ -791,3 +819,21 @@ jQuery( function( $ ) {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Removed in 5.6.0, needed for back-compatibility.
|
||||
*
|
||||
* @since 4.8.0
|
||||
* @deprecated 5.6.0
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
window.communityEventsData.l10n = window.communityEventsData.l10n || {
|
||||
enter_closest_city: '',
|
||||
error_occurred_please_try_again: '',
|
||||
attend_event_near_generic: '',
|
||||
could_not_locate_city: '',
|
||||
city_updated: ''
|
||||
};
|
||||
|
||||
window.communityEventsData.l10n = window.wp.deprecateL10nObject( 'communityEventsData.l10n', window.communityEventsData.l10n, '5.6.0' );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1023,4 +1023,4 @@ wp.themePluginEditor.l10n = wp.themePluginEditor.l10n || {
|
|||
}
|
||||
};
|
||||
|
||||
wp.themePluginEditor.l10n = window.wp.deprecateL10nObject( 'wp.themePluginEditor.l10n', wp.themePluginEditor.l10n );
|
||||
wp.themePluginEditor.l10n = window.wp.deprecateL10nObject( 'wp.themePluginEditor.l10n', wp.themePluginEditor.l10n, '5.5.0' );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -115,7 +115,7 @@
|
|||
autoUpdatesError: ''
|
||||
};
|
||||
|
||||
wp.updates.l10n = window.wp.deprecateL10nObject( 'wp.updates.l10n', wp.updates.l10n );
|
||||
wp.updates.l10n = window.wp.deprecateL10nObject( 'wp.updates.l10n', wp.updates.l10n, '5.5.0' );
|
||||
|
||||
/**
|
||||
* User nonce for ajax calls.
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -760,4 +760,4 @@ wpWidgets.l10n = wpWidgets.l10n || {
|
|||
widgetAdded: ''
|
||||
};
|
||||
|
||||
wpWidgets.l10n = window.wp.deprecateL10nObject( 'wpWidgets.l10n', wpWidgets.l10n );
|
||||
wpWidgets.l10n = window.wp.deprecateL10nObject( 'wpWidgets.l10n', wpWidgets.l10n, '5.5.0' );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1757,34 +1757,6 @@ function wp_localize_community_events() {
|
|||
'nonce' => wp_create_nonce( 'community_events' ),
|
||||
'cache' => $events_client->get_cached_events(),
|
||||
'time_format' => get_option( 'time_format' ),
|
||||
|
||||
'l10n' => array(
|
||||
'enter_closest_city' => __( 'Enter your closest city to find nearby events.' ),
|
||||
'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ),
|
||||
'attend_event_near_generic' => __( 'Attend an upcoming event near you.' ),
|
||||
|
||||
/*
|
||||
* These specific examples were chosen to highlight the fact that a
|
||||
* state is not needed, even for cities whose name is not unique.
|
||||
* It would be too cumbersome to include that in the instructions
|
||||
* to the user, so it's left as an implication.
|
||||
*/
|
||||
/*
|
||||
* translators: %s is the name of the city we couldn't locate.
|
||||
* Replace the examples with cities related to your locale. Test that
|
||||
* they match the expected location and have upcoming events before
|
||||
* including them. If no cities related to your locale have events,
|
||||
* then use cities related to your locale that would be recognizable
|
||||
* to most users. Use only the city name itself, without any region
|
||||
* or country. Use the endonym (native locale name) instead of the
|
||||
* English name if possible.
|
||||
*/
|
||||
'could_not_locate_city' => __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
|
||||
|
||||
// This one is only used with wp.a11y.speak(), so it can/should be more brief.
|
||||
/* translators: %s: The name of a city. */
|
||||
'city_updated' => __( 'City updated. Listing events near %s.' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.6-alpha-49150';
|
||||
$wp_version = '5.6-alpha-49151';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue