WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/18/17 14:33:04 (4 months ago)
Author:
obenland
Message:

Dashboard: Properly localize data for events

Moves localization to script-loader and removes dependency for two strings.

Props dd32, iandunn.
See #40702.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r40775 r40776  
    10021002 
    10031003/** 
     1004 * Localizes community events data that needs to be passed to dashboard.js. 
     1005 * 
     1006 * @since 4.8.0 
     1007 */ 
     1008function wp_localize_community_events() { 
     1009    if ( ! wp_script_is( 'dashboard' ) ) { 
     1010        return; 
     1011    } 
     1012 
     1013    require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' ); 
     1014 
     1015    $user_id       = get_current_user_id(); 
     1016    $user_location = get_user_option( 'community-events-location', $user_id ); 
     1017    $events_client = new WP_Community_Events( $user_id, $user_location ); 
     1018 
     1019    wp_localize_script( 'dashboard', 'communityEventsData', array( 
     1020        'nonce' => wp_create_nonce( 'community_events' ), 
     1021        'cache' => $events_client->get_cached_events(), 
     1022 
     1023        'l10n' => array( 
     1024            'enter_closest_city' => __( 'Enter your closest city to find nearby events.' ), 
     1025            'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ), 
     1026 
     1027            /* 
     1028             * These specific examples were chosen to highlight the fact that a 
     1029             * state is not needed, even for cities whose name is not unique. 
     1030             * It would be too cumbersome to include that in the instructions 
     1031             * to the user, so it's left as an implication. 
     1032             */ 
     1033            /* translators: %s is the name of the city we couldn't locate. Replace the examples with cities in your locale, but test that they match the expected location before including them. Use endonyms (native locale names) whenever possible. */ 
     1034            'could_not_locate_city' => __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ), 
     1035 
     1036            // This one is only used with wp.a11y.speak(), so it can/should be more brief. 
     1037            /* translators: %s is the name of a city. */ 
     1038            'city_updated' => __( 'City updated. Listing events near %s.' ), 
     1039        ) 
     1040    ) ); 
     1041} 
     1042 
     1043/** 
    10041044 * Administration Screen CSS for changing the styles. 
    10051045 * 
Note: See TracChangeset for help on using the changeset viewer.