Skip to content
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dbb6cc5
WS-2759: Refactors most read to extract function
Isabella-Mitchell Jun 2, 2026
8fc1bdc
WS-2759: Translates sports data scores
Isabella-Mitchell Jun 2, 2026
3040f0c
WS-2759: Adds further sport translations - initial service
Isabella-Mitchell Jun 3, 2026
e5d797d
WS-2759: Adds further sport translations [copilot]
Isabella-Mitchell Jun 3, 2026
d606c47
WS-2759: Apply periodLabel and groupActions translations
Isabella-Mitchell Jun 3, 2026
c34620f
Merge branch 'WS-2706-world-cup-team-name-translations' into WS-2759-…
Isabella-Mitchell Jun 3, 2026
5dcd92c
WS-2756: Adds winOnPens translations - intial service
Isabella-Mitchell Jun 3, 2026
b9df3e1
WS-2756: Adds remaining winOnPens translations [copilot]
Isabella-Mitchell Jun 3, 2026
dd18b64
WS-2756: Renders translated winsOnPens text
Isabella-Mitchell Jun 3, 2026
1bbaa7c
WS-2756: Add translation transformer unit tests
Isabella-Mitchell Jun 3, 2026
e40edbf
WS-2759: Fix hardcoded fallback bugs
Isabella-Mitchell Jun 3, 2026
0496e87
WS-2759: Update imports in e2e tests
Isabella-Mitchell Jun 3, 2026
07cb58b
WS-2759: Tidies comments
Isabella-Mitchell Jun 3, 2026
d468a92
WS-2759: Add edge case handling and tests
Isabella-Mitchell Jun 3, 2026
407f159
WS-2759: Adds tests and initial workings for translating minutes
Isabella-Mitchell Jun 3, 2026
6d81a6d
WS-2759: Translates minutes in period label to numerals
Isabella-Mitchell Jun 3, 2026
2fb4a06
WS-2759: Adds persian translations
Isabella-Mitchell Jun 4, 2026
c30baf2
WS-2759: fixes translate minutes logic. Adds tests
Isabella-Mitchell Jun 4, 2026
e9cc381
WS-2759: Fix test typo
Isabella-Mitchell Jun 4, 2026
6e1cec5
WS-2759: Refactors periodLabel
Isabella-Mitchell Jun 4, 2026
bf5f5b9
WS-2759: Uses check to only translate score when needed
Isabella-Mitchell Jun 4, 2026
8e75aa9
WS-2759: Translates action numerals and type if applicable
Isabella-Mitchell Jun 4, 2026
d7d5066
WS-2759: Tidies
Isabella-Mitchell Jun 4, 2026
4510b56
WS-2759: Tidy
Isabella-Mitchell Jun 4, 2026
bc79de3
WS-2759: Translate groupAction numerals
Isabella-Mitchell Jun 4, 2026
57cc140
WS-2759: Tidy types
Isabella-Mitchell Jun 4, 2026
59b0f97
WS-2759: Tidies
Isabella-Mitchell Jun 5, 2026
907c28d
WS-2759: Initial own goal
Isabella-Mitchell Jun 5, 2026
f0f736f
WS-2759: Refactors actionTime
Isabella-Mitchell Jun 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
import { use } from 'react';
import { ServiceContext } from '#app/contexts/ServiceContext';
import VisuallyHiddenText from '../../../../components/VisuallyHiddenText';
import styles from '../index.styles';
import Card from './card';
import type { PlayerActions } from '../types';

// TODO - get a translation for this
const goalTypesHandled: Record<string, string> = {
Penalty: 'pen',
'Own Goal': 'og',
Comment thread
Isabella-Mitchell marked this conversation as resolved.
Outdated
};

const displayGoalType = (goalType: string) =>
goalTypesHandled[goalType] ? ` ${goalTypesHandled[goalType]}` : '';
const displayGoalType = (goalType: string, penaltiesTranslation: string) => {
if (goalType === 'Penalty') {
return ` ${penaltiesTranslation}`;
}

if (goalTypesHandled[goalType]) {
return ` ${goalTypesHandled[goalType]}`;
}

return '';
};

interface ActionsTimeProps {
player: PlayerActions;
}

const ActionsTime = ({ player }: ActionsTimeProps) => {
const { translations } = use(ServiceContext);
const penaltiesTranslation =
translations?.sport?.penaltyAbbreviation || 'pen';

const times = player.actions.map(
action => `${action.timeLabel.value}${displayGoalType(action.type)}`,
action =>
`${action.timeLabel.translated || action.timeLabel.value}${displayGoalType(action.type, penaltiesTranslation)}`,
);
const timesAccessible = player.actions
.map(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable import/prefer-default-export */
import { use } from 'react';
import { ServiceContext } from '#app/contexts/ServiceContext';
import GroupedEvents from './grouped-events';
import ActionGrid from './action-grid';
import ScoreDetails from './score-details';
Expand All @@ -10,6 +12,8 @@ interface ActionsProps {
}

export const Actions = ({ data }: ActionsProps) => {
const { translations } = use(ServiceContext);

const homeKeyEvents = data.home?.actions || [];
const awayKeyEvents = data.away?.actions || [];

Expand All @@ -25,6 +29,7 @@ export const Actions = ({ data }: ActionsProps) => {
awayName={data.away.fullName}
homeRunningScores={data.home.runningScores}
awayRunningScores={data.away.runningScores}
translations={translations?.sport}
/>
{hasKeyEvents && (
<KeyEvents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ const MatchProgress = ({ data, isConciseView }: MatchProgressProps) => {

const fallbackPeriod =
periodLabel &&
getFallbackFootballPeriodLabel(
periodLabel,
getFallbackFootballPeriodLabel({
labels: periodLabel,
status,
home.runningScores,
away.runningScores,
home.fullName,
away.fullName,
);
homeRunningScores: home.runningScores,
awayRunningScores: away.runningScores,
homeName: home.fullName,
awayName: away.fullName,
});

const shouldDisplayPeriod =
periodLabel && fallbackPeriod && shouldShowScores(status);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { use } from 'react';
import { ServiceContext } from '#app/contexts/ServiceContext';
import VisuallyHiddenText from '../../../../components/VisuallyHiddenText';
import styles from '../index.styles';
import type { HeadToHeadV2Data } from '../types';
Expand All @@ -9,6 +11,11 @@ interface PenaltyScoresProps {
const PenaltyScores = ({ data }: PenaltyScoresProps) => {
const { winner, seriesWinner, multiLeg, status } = data;

const { translations } = use(ServiceContext);
const { winOnPenalties } = translations?.sport || {};
const { prefix = 'win', suffix = 'on penalties' } = winOnPenalties ?? {};
const shortSuffix = suffix === 'on penalties' ? 'on pens' : suffix;

const isPostEvent = status?.toLowerCase() === 'postevent';
const hasWinner = winner !== undefined;
const isDrawWithNoSeriesWinner = winner === 'draw' && !seriesWinner;
Expand Down Expand Up @@ -36,15 +43,15 @@ const PenaltyScores = ({ data }: PenaltyScoresProps) => {
return (
<div css={styles.penaltyScoresContainer}>
<VisuallyHiddenText>
{`${winnerOnPenaltiesName} win ${winnerOnPenaltiesScore} - ${loserOnPenaltiesScore} on penalties`}
{`${winnerOnPenaltiesName} ${prefix} ${winnerOnPenaltiesScore} - ${loserOnPenaltiesScore} ${suffix}`}
</VisuallyHiddenText>
Comment thread
Isabella-Mitchell marked this conversation as resolved.
<div
css={styles.penaltiesText}
aria-hidden="true"
data-testid="penalties-text"
>
<span css={styles.winningTeamName}>{`${winnerOnPenaltiesName}`}</span>
{` win ${winnerOnPenaltiesScore}-${loserOnPenaltiesScore} on pens`}
{` ${prefix} ${winnerOnPenaltiesScore}-${loserOnPenaltiesScore} ${shortSuffix}`}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { use } from 'react';
import { ServiceContext } from '#app/contexts/ServiceContext';
import { getFallbackFootballPeriodLabel } from '../helpers/event-summary';
import styles from '../index.styles';
import type { EventStatusType, RunningScores } from '../types';

interface PeriodLabels {
value: string;
accessible: string;
translation?: string;
}

interface PeriodProps {
Expand All @@ -20,15 +23,20 @@ const Period = ({
homeRunningScores,
awayRunningScores,
}: PeriodProps) => {
const period = getFallbackFootballPeriodLabel(
const { translations } = use(ServiceContext);

const period = getFallbackFootballPeriodLabel({
labels,
status,
homeRunningScores,
awayRunningScores,
);
translations: translations?.sport,
});

const periodValue = period?.translation || period?.value;
return (
<div css={styles.period} aria-hidden="true">
<div>{period.value}</div>
<div>{periodValue}</div>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Translations } from '#app/models/types/translations';
import VisuallyHiddenText from '../../../../components/VisuallyHiddenText';
import styles from '../index.styles';
import type { RunningScores } from '../types';
Expand All @@ -7,13 +8,15 @@ interface ScoreDetailsProps {
awayName: string;
homeRunningScores?: RunningScores;
awayRunningScores?: RunningScores;
translations?: Translations['sport'];
}

const ScoreDetails = ({
homeName,
awayName,
homeRunningScores,
awayRunningScores,
translations,
}: ScoreDetailsProps) => {
const shouldDisplayHT = Boolean(
homeRunningScores?.halftime && awayRunningScores?.halftime,
Expand All @@ -29,27 +32,31 @@ const ScoreDetails = ({
return null;
}

const { ft = 'FT', ht = 'HT' } = translations || {};
const ftAccessible = ft === 'FT' ? 'Full Time' : ft;
const htAccessible = ht === 'HT' ? 'Half Time' : ht;

return (
<div css={styles.scoreDetailsWrapper}>
{shouldDisplayFT && (
<>
<VisuallyHiddenText>{`Full Time ${homeName} ${homeRunningScores?.fulltime} , ${awayName} ${awayRunningScores?.fulltime}`}</VisuallyHiddenText>
<VisuallyHiddenText>{`${ftAccessible} ${homeName} ${homeRunningScores?.fulltime} , ${awayName} ${awayRunningScores?.fulltime}`}</VisuallyHiddenText>

<div
css={styles.scoreDetailsScore}
aria-hidden="true"
>{`FT ${homeRunningScores?.fulltime}-${awayRunningScores?.fulltime}`}</div>
>{`${ft} ${homeRunningScores?.fulltime}-${awayRunningScores?.fulltime}`}</div>

<span css={styles.scoreDetailsComma}>,</span>
</>
)}
{shouldDisplayHT && (
<>
<VisuallyHiddenText>{`Half Time ${homeName} ${homeRunningScores?.halftime} , ${awayName} ${awayRunningScores?.halftime}`}</VisuallyHiddenText>{' '}
<VisuallyHiddenText>{`${htAccessible} ${homeName} ${homeRunningScores?.halftime} , ${awayName} ${awayRunningScores?.halftime}`}</VisuallyHiddenText>{' '}
<div
css={styles.scoreDetailsScore}
aria-hidden="true"
>{`HT ${homeRunningScores?.halftime}-${awayRunningScores?.halftime}`}</div>
>{`${ht} ${homeRunningScores?.halftime}-${awayRunningScores?.halftime}`}</div>
</>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const HeadToHeadV2 = ({
isSportDataLive?: boolean;
}) => {
const { enabled: sportHeaderPollEnabled } = useToggle('sportDataPolling');
const { translations } = use(ServiceContext);
const { translations, service } = use(ServiceContext);

const { currentSportData } = useSportDataPolling(
initialSportData,
Expand All @@ -42,6 +42,7 @@ export const HeadToHeadV2 = ({
const translatedSportData = translateSportData(
currentSportData,
translations,
service,
);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Translations } from '#app/models/types/translations';
import { EventStatus, HeadToHeadV2Data } from '../types';

const ftFallback = { value: 'FT', accessible: 'Full time' };
const aetFallback = { value: 'AET', accessible: 'After extra time' };

type PeriodLabel = { value: string; accessible: string };
type PeriodLabel = { value: string; accessible: string; translation?: string };

type RunningScores = {
halftime?: string;
Expand All @@ -30,16 +31,33 @@ type EventSummaryParams = {
period?: string;
};

export const getFallbackFootballPeriodLabel = (
labels: PeriodLabel,
status: EventStatus | string,
homeRunningScores?: RunningScores,
awayRunningScores?: RunningScores,
homeName?: string,
awayName?: string,
): PeriodLabel => {
type FallbackPeriodLabelParams = {
labels: PeriodLabel;
status: EventStatus | string;
homeRunningScores?: RunningScores;
awayRunningScores?: RunningScores;
homeName?: string;
awayName?: string;
translations?: Translations['sport'];
};

export const getFallbackFootballPeriodLabel = ({
labels,
status,
homeRunningScores,
awayRunningScores,
homeName,
awayName,
translations,
}: FallbackPeriodLabelParams): PeriodLabel => {
const isPens = labels?.value?.toLowerCase() === 'pens';

const {
penalties: penaltiesTranslation = 'Penalties',
afterExtraTime: aetTranslation,
ft: ftTranslation,
} = translations || {};

if (status?.toLowerCase() === 'midevent' && isPens) {
const accessibleText = [
homeName,
Expand All @@ -56,15 +74,28 @@ export const getFallbackFootballPeriodLabel = (
: '';

return {
value: `Penalties${scoreText}`,
accessible: `Penalties ${accessibleText}`,
value: `${penaltiesTranslation}${scoreText}`,
accessible: `${penaltiesTranslation} ${accessibleText}`,
};
}

if (isPens) {
return homeRunningScores?.extratime && awayRunningScores?.extratime
? aetFallback
const aetTranslatedFallback = aetTranslation
? {
value: aetTranslation,
accessible: aetTranslation,
}
: aetFallback;
const ftTranslatedFallback = ftTranslation
? {
value: ftTranslation,
accessible: ftTranslation,
}
: ftFallback;
Comment on lines +83 to 94

return homeRunningScores?.extratime && awayRunningScores?.extratime
? aetTranslatedFallback
: ftTranslatedFallback;
}

return labels;
Expand Down Expand Up @@ -149,12 +180,12 @@ export const getConciseFootballEventSummary = ({
summary.push('at');
}

const fallbackPeriod = getFallbackFootballPeriodLabel(
periodLabel ?? ftFallback,
const fallbackPeriod = getFallbackFootballPeriodLabel({
labels: periodLabel ?? ftFallback,
status,
home.runningScores,
away.runningScores,
);
homeRunningScores: home.runningScores,
awayRunningScores: away.runningScores,
});

summary.push(fallbackPeriod.accessible);

Expand Down
Loading
Loading