Include Date component required settings in app-wide settings object instead of using experimental retrieval from @wordpress/date.

This commit is contained in:
Jeff Stieler 2018-12-10 16:05:45 -07:00
parent 4d37bdc67c
commit 3285ac4980
2 changed files with 9 additions and 5 deletions

View File

@ -130,6 +130,8 @@ function format_order_statuses( $statuses ) {
* Output the wcSettings global before printing any script tags.
*/
function wc_admin_print_script_settings() {
global $wp_locale;
// Add Tracks script to the DOM if tracking is opted in, and Jetpack is installed/activated.
$tracking_enabled = 'yes' === get_option( 'woocommerce_allow_tracking', 'no' );
$tracking_script = '';
@ -179,6 +181,10 @@ function wc_admin_print_script_settings() {
'siteTitle' => get_bloginfo( 'name' ),
'trackingEnabled' => $tracking_enabled,
'dataEndpoints' => array(),
'l10n' => array(
'userLocale' => get_user_locale(),
'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
),
);
foreach ( $preload_data_endpoints as $key => $endpoint ) {

View File

@ -5,7 +5,7 @@
import moment from 'moment';
import { find } from 'lodash';
import { __ } from '@wordpress/i18n';
import { __experimentalGetSettings, format as formatDate } from '@wordpress/date';
import { format as formatDate } from '@wordpress/date';
const QUERY_DEFAULTS = {
pageSize: 25,
@ -491,10 +491,8 @@ export function getDateFormatsForInterval( interval, ticks = 0 ) {
* we can use that data and enhance it with additional translations
*/
export function loadLocaleData() {
const { date } = wcSettings;
const settings = __experimentalGetSettings();
const userLocale = settings.l10n.locale;
const { weekdaysShort } = settings.l10n;
const { date, l10n } = wcSettings;
const { userLocale, weekdaysShort } = l10n;
// Keep the default Momentjs English settings for any English
if ( ! userLocale.match( /en_/ ) ) {