Skip to content

Commit

Permalink
chore(explore): Properly pluralize confidence copy (#85431)
Browse files Browse the repository at this point in the history
Because we're using `tct` here, we need to use a separate message for
each possibility.
  • Loading branch information
Zylphrex authored Feb 19, 2025
1 parent 476f253 commit 4779f43
Showing 1 changed file with 49 additions and 12 deletions.
61 changes: 49 additions & 12 deletions static/app/views/explore/charts/confidenceFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,69 @@ function confidenceMessage({sampleCount, confidence, topEvents}: Props) {
}

if (confidence === 'low') {
return isTopN
? tct(
'* Chart for top [topEvents] groups extrapolated from [sampleCount] sample(s) ([lowAccuracy])',
if (isTopN) {
if (sampleCount === 1) {
return tct(
'* Chart for top [topEvents] groups extrapolated from [sampleCount] sample ([lowAccuracy])',
{
topEvents,
sampleCount: <Count value={sampleCount} />,
lowAccuracy: <LowAccuracy />,
}
)
: tct('* Chart extrapolated from [sampleCount] sample(s) ([lowAccuracy])', {
);
}
return tct(
'* Chart for top [topEvents] groups extrapolated from [sampleCount] samples ([lowAccuracy])',
{
topEvents,
sampleCount: <Count value={sampleCount} />,
lowAccuracy: <LowAccuracy />,
});
}
);
}

if (sampleCount === 1) {
return tct('* Chart extrapolated from [sampleCount] sample ([lowAccuracy])', {
sampleCount: <Count value={sampleCount} />,
lowAccuracy: <LowAccuracy />,
});
}

return tct('* Chart extrapolated from [sampleCount] samples ([lowAccuracy])', {
sampleCount: <Count value={sampleCount} />,
lowAccuracy: <LowAccuracy />,
});
}

return isTopN
? tct(
'* Chart for top [topEvents] groups extrapolated from [sampleCount] sample(s)',
if (isTopN) {
if (sampleCount === 1) {
return tct(
'* Chart for top [topEvents] groups extrapolated from [sampleCount] sample',
{
topEvents,
sampleCount: <Count value={sampleCount} />,
}
)
: tct('* Chart extrapolated from [sampleCount] sample(s)', {
);
}

return tct(
'* Chart for top [topEvents] groups extrapolated from [sampleCount] sample',
{
topEvents,
sampleCount: <Count value={sampleCount} />,
});
}
);
}

if (sampleCount === 1) {
return tct('* Chart extrapolated from [sampleCount] sample', {
sampleCount: <Count value={sampleCount} />,
});
}

return tct('* Chart extrapolated from [sampleCount] samples', {
sampleCount: <Count value={sampleCount} />,
});
}

function LowAccuracy() {
Expand Down

0 comments on commit 4779f43

Please sign in to comment.