diff --git a/modules/search/class.jetpack-search.php b/modules/search/class.jetpack-search.php index 396bd4a62d32d..99c3b9ed661f0 100644 --- a/modules/search/class.jetpack-search.php +++ b/modules/search/class.jetpack-search.php @@ -222,6 +222,7 @@ public function load_assets() { 'postTypes' => get_post_types(), 'siteId' => Jetpack::get_option( 'id' ), 'widgets' => array_values( $widgets ), + 'locale' => str_replace( '_', '-', get_locale() ), ); /** * Customize Instant Search Options. diff --git a/modules/search/instant-search/components/search-app.jsx b/modules/search/instant-search/components/search-app.jsx index f17779f5be9ae..3cf3a0c6de60d 100644 --- a/modules/search/instant-search/components/search-app.jsx +++ b/modules/search/instant-search/components/search-app.jsx @@ -161,6 +161,7 @@ class SearchApp extends Component { initialValues={ this.props.initialFilters } onChange={ this.onChangeFilter } loading={ this.state.isLoading } + locale={ this.props.options.locale } postTypes={ this.props.options.postTypes } results={ this.state.response } widget={ widget } @@ -185,6 +186,7 @@ class SearchApp extends Component { hasNextPage={ this.hasNextPage() } isLoading={ this.state.isLoading } onLoadNextPage={ this.loadNextPage } + locale={ this.props.options.locale } query={ this.state.query } response={ this.state.response } resultFormat={ this.props.options.resultFormat } diff --git a/modules/search/instant-search/components/search-filter-dates.jsx b/modules/search/instant-search/components/search-filter-dates.jsx index 38332f36b8656..904884b44f8e7 100644 --- a/modules/search/instant-search/components/search-filter-dates.jsx +++ b/modules/search/instant-search/components/search-filter-dates.jsx @@ -4,7 +4,6 @@ * External dependencies */ import { h, createRef, Component } from 'preact'; -import strip from 'strip'; import { getCheckedInputNames } from '../lib/dom'; export default class SearchFilterDates extends Component { @@ -12,6 +11,33 @@ export default class SearchFilterDates extends Component { super( props ); this.state = { selected: this.props.initialValue }; this.filtersList = createRef(); + + //this assumes that the configuration never changes and we + // may eventually want to adjust it dynamically + this.dateOptions = { + year: 'numeric', + month: 'long', + }; + switch ( this.props.configuration.interval ) { + case 'day': + this.dateOptions = { + year: 'numeric', + month: 'long', + day: 'numeric', + }; + break; + case 'month': + this.dateOptions = { + year: 'numeric', + month: 'long', + }; + break; + case 'year': + this.dateOptions = { + year: 'numeric', + }; + break; + } } getIdentifier() { @@ -28,6 +54,7 @@ export default class SearchFilterDates extends Component { }; renderDates = ( { key_as_string: key, doc_count: count } ) => { + const { locale = 'en-US' } = this.props; return (