Skip to content

Commit

Permalink
fix(UI): add plurality to heatmap tooltip (freeCodeCamp#58282)
Browse files Browse the repository at this point in the history
Co-authored-by: Naomi <[email protected]>
  • Loading branch information
RaymondLiu777 and naomi-lgbt authored Jan 30, 2025
1 parent 84d246e commit 6abaee5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions client/i18n/locales/english/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@
"joined": "Joined {{date}}",
"from": "From {{location}}",
"total-points": "Total Points:",
"points": "{{count}} point on {{date}}",
"points_plural": "{{count}} points on {{date}}",
"points-singular": "{{count}} point on {{date}}",
"points-plural": "{{count}} points on {{date}}",
"page-number": "{{pageNumber}} of {{totalPages}}",
"edit-my-profile": "Edit My Profile",
"add-bluesky": "Share this certification on BlueSky",
Expand Down
23 changes: 16 additions & 7 deletions client/src/components/profile/components/heat-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,23 @@ class HeatMapInner extends Component<HeatMapInnerProps, HeatMapInnerState> {
day: 'numeric'
})
: '';
if (!value || value.count < 0) {
return { 'data-tip': '' };
}
// Use singular translation if count == 1 else plural
if (value.count === 1) {
return {
'data-tip': t('profile.points-singular', {
count: value.count,
date: dateFormatted
})
};
}
return {
'data-tip':
value && value.count > -1
? t('profile.points', {
count: value.count,
date: dateFormatted
})
: ''
'data-tip': t('profile.points-plural', {
count: value.count,
date: dateFormatted
})
};
}}
values={dataToDisplay}
Expand Down

0 comments on commit 6abaee5

Please sign in to comment.