Skip to content

Commit 90fc40f

Browse files
committed
Pluralize
1 parent 39a2a4b commit 90fc40f

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

options/locale/locale_en-US.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ number_of_contributions_in_the_last_12_months = %s contributions in the last 12
125125
no_contributions = No contributions
126126
less = Less
127127
more = More
128-
number_of_contributions_on_date = <b>%[1]s contributions</b> on %[2]s
128+
number_of_contributions_on_date_n = <b>%[2]s contributions</b> on %[1]s
129+
number_of_contributions_on_date_1 = <b>1 contribution</b> on %[1]s
129130

130131
[editor]
131132
buttons.heading.tooltip = Add heading

templates/user/heatmap.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
data-locale-no-contributions="{{.locale.Tr "heatmap.no_contributions"}}"
66
data-locale-more="{{.locale.Tr "heatmap.more"}}"
77
data-locale-less="{{.locale.Tr "heatmap.less"}}"
8-
data-locale-contributions-on="{{.locale.Tr "heatmap.number_of_contributions_on_date"}}"
8+
data-locale-contributions-on-n="{{.locale.Tr "heatmap.number_of_contributions_on_date_n"}}"
9+
data-locale-contributions-on-1="{{.locale.Tr "heatmap.number_of_contributions_on_date_1"}}"
910
>
1011
<div slot="loading">
1112
<div class="ui active centered inline indeterminate text loader" id="loading-heatmap">{{.locale.Tr "user.heatmap.loading"}}</div>

web_src/js/components/ActivityHeatmap.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ export default {
7070
const datetime = v.date.toISOString();
7171
const fallback = v.date.toLocaleDateString();
7272
const date = `<relative-time format="datetime" year="numeric" month="short" day="numeric" weekday="" datetime="${datetime}">${fallback}</relative-time>`;
73-
return locale.contributions_on.replace('%[1]s', number).replace('%[2]s', date);
73+
const stringToFormat = v.count === 1 ? locale.contributions_on_1 : locale.contributions_on_n;
74+
return stringToFormat.replace('%[2]s', number).replace('%[1]s', date);
7475
}
7576
},
7677
};

web_src/js/features/heatmap.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export function initHeatmap() {
2525
no_contributions: el.getAttribute('data-locale-no-contributions'),
2626
more: el.getAttribute('data-locale-more'),
2727
less: el.getAttribute('data-locale-less'),
28-
contributions_on: el.getAttribute('data-locale-contributions-on'),
28+
contributions_on_n: el.getAttribute('data-locale-contributions-on-n'),
29+
contributions_on_1: el.getAttribute('data-locale-contributions-on-1'),
2930
};
3031

3132
const View = createApp(ActivityHeatmap, {values, locale});

0 commit comments

Comments
 (0)