summaryrefslogtreecommitdiffstatshomepage
path: root/src/js/_enqueues/wp/dashboard.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/_enqueues/wp/dashboard.js')
-rw-r--r--src/js/_enqueues/wp/dashboard.js60
1 files changed, 53 insertions, 7 deletions
diff --git a/src/js/_enqueues/wp/dashboard.js b/src/js/_enqueues/wp/dashboard.js
index 87a8493128..87a2191967 100644
--- a/src/js/_enqueues/wp/dashboard.js
+++ b/src/js/_enqueues/wp/dashboard.js
@@ -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' );