Skip to content

Commit

Permalink
i18n: Fix translate calls in JP stats (#97545)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskmnds authored Dec 19, 2024
1 parent 170d272 commit 7733985
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
22 changes: 11 additions & 11 deletions client/components/date-range/use-shortcuts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import config from '@automattic/calypso-config';
import { createSelector } from '@automattic/state-utils';
import { translate, useTranslate } from 'i18n-calypso';
import { translate as i18nCalypsoTranslate, useTranslate } from 'i18n-calypso';
import { getMomentSiteZone } from 'calypso/my-sites/stats/hooks/use-moment-site-zone';
import { useSelector } from 'calypso/state';
import { getSelectedSiteId } from 'calypso/state/ui/selectors';
Expand Down Expand Up @@ -41,10 +41,10 @@ export const getShortcuts = createSelector(
chartStart: string;
chartEnd: string;
},
translateFunction,
translateFromProps,
isNewDateFilteringEnabled = config.isEnabled( 'stats/new-date-filtering' )
) => {
translateFunction = translateFunction ?? translate;
const translate = translateFromProps ?? i18nCalypsoTranslate;
const siteId = getSelectedSiteId( state );
const siteToday = getMomentSiteZone( state, siteId );
const siteTodayStr = siteToday.format( DATE_FORMAT );
Expand All @@ -54,35 +54,35 @@ export const getShortcuts = createSelector(
const supportedShortcutList = [
{
id: 'last_7_days',
label: translateFunction( 'Last 7 Days' ),
label: translate( 'Last 7 Days' ),
startDate: siteToday.clone().subtract( 6, 'days' ).format( DATE_FORMAT ),
endDate: siteTodayStr,
period: DATERANGE_PERIOD.DAY,
},
{
id: 'last_30_days',
label: translateFunction( 'Last 30 Days' ),
label: translate( 'Last 30 Days' ),
startDate: siteToday.clone().subtract( 29, 'days' ).format( DATE_FORMAT ),
endDate: siteTodayStr,
period: DATERANGE_PERIOD.DAY,
},
{
id: 'last_3_months',
label: translateFunction( 'Last 90 Days' ),
label: translate( 'Last 90 Days' ),
startDate: siteToday.clone().subtract( 89, 'days' ).format( DATE_FORMAT ),
endDate: siteTodayStr,
period: DATERANGE_PERIOD.WEEK,
},
{
id: 'last_year',
label: translateFunction( 'Last Year' ),
label: translate( 'Last Year' ),
startDate: siteToday.clone().subtract( 364, 'days' ).format( DATE_FORMAT ),
endDate: siteTodayStr,
period: DATERANGE_PERIOD.MONTH,
},
{
id: 'custom_date_range',
label: translateFunction( 'Custom Range' ),
label: translate( 'Custom Range' ),
startDate: '',
endDate: '',
period: DATERANGE_PERIOD.DAY,
Expand All @@ -93,14 +93,14 @@ export const getShortcuts = createSelector(
supportedShortcutList.unshift(
{
id: 'today',
label: translateFunction( 'Today' ),
label: translate( 'Today' ),
startDate: siteTodayStr,
endDate: siteTodayStr,
period: DATERANGE_PERIOD.DAY,
},
{
id: 'yesterday',
label: translateFunction( 'Yesterday' ),
label: translate( 'Yesterday' ),
startDate: yesterdayStr,
endDate: yesterdayStr,
period: DATERANGE_PERIOD.DAY,
Expand All @@ -119,7 +119,7 @@ export const getShortcuts = createSelector(
chartStart: string;
chartEnd: string;
},
translateFunction,
translateFromProps,
isNewDateFilteringEnabled
) => {
const siteId = getSelectedSiteId( state );
Expand Down
8 changes: 4 additions & 4 deletions client/my-sites/stats/stats-period-navigation/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { recordTracksEvent } from '@automattic/calypso-analytics';
import page from '@automattic/calypso-router';
import clsx from 'clsx';
import { localize, translate, withRtl } from 'i18n-calypso';
import { localize, withRtl } from 'i18n-calypso';
import { flowRight } from 'lodash';
import PropTypes from 'prop-types';
import qs from 'qs';
Expand Down Expand Up @@ -363,7 +363,7 @@ const addIsGatedFor = ( state, siteId ) => ( shortcut ) => ( {
} );

const connectComponent = connect(
( state, { period, isNewDateFilteringEnabled } ) => {
( state, { period, isNewDateFilteringEnabled, translate } ) => {
const siteId = getSelectedSiteId( state );
const gateDateControl = shouldGateStats( state, siteId, STATS_FEATURE_DATE_CONTROL );
const gatePeriodInterval = shouldGateStats(
Expand All @@ -378,7 +378,7 @@ const connectComponent = connect(
const { supportedShortcutList } = getShortcuts(
state,
{},
undefined,
translate,
isNewDateFilteringEnabled
);
const shortcutList = supportedShortcutList.map( addIsGatedFor( state, siteId ) );
Expand Down Expand Up @@ -423,8 +423,8 @@ const connectComponent = connect(
);

export default flowRight(
connectComponent,
localize,
connectComponent,
withRtl,
withLocalizedMoment,
withStatsPurchases
Expand Down

0 comments on commit 7733985

Please sign in to comment.