Skip to content

Commit 6abaee5

Browse files
fix(UI): add plurality to heatmap tooltip (freeCodeCamp#58282)
Co-authored-by: Naomi <accounts+github@nhcarrigan.com>
1 parent 84d246e commit 6abaee5

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

client/i18n/locales/english/translations.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@
366366
"joined": "Joined {{date}}",
367367
"from": "From {{location}}",
368368
"total-points": "Total Points:",
369-
"points": "{{count}} point on {{date}}",
370-
"points_plural": "{{count}} points on {{date}}",
369+
"points-singular": "{{count}} point on {{date}}",
370+
"points-plural": "{{count}} points on {{date}}",
371371
"page-number": "{{pageNumber}} of {{totalPages}}",
372372
"edit-my-profile": "Edit My Profile",
373373
"add-bluesky": "Share this certification on BlueSky",

client/src/components/profile/components/heat-map.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,23 @@ class HeatMapInner extends Component<HeatMapInnerProps, HeatMapInnerState> {
125125
day: 'numeric'
126126
})
127127
: '';
128+
if (!value || value.count < 0) {
129+
return { 'data-tip': '' };
130+
}
131+
// Use singular translation if count == 1 else plural
132+
if (value.count === 1) {
133+
return {
134+
'data-tip': t('profile.points-singular', {
135+
count: value.count,
136+
date: dateFormatted
137+
})
138+
};
139+
}
128140
return {
129-
'data-tip':
130-
value && value.count > -1
131-
? t('profile.points', {
132-
count: value.count,
133-
date: dateFormatted
134-
})
135-
: ''
141+
'data-tip': t('profile.points-plural', {
142+
count: value.count,
143+
date: dateFormatted
144+
})
136145
};
137146
}}
138147
values={dataToDisplay}

0 commit comments

Comments
 (0)