Fix heatmap localization

Fixes #2552
This commit is contained in:
0ko 2024-03-19 14:37:03 +05:00
parent 226fa396df
commit 708f4bc3b6
25 changed files with 57 additions and 33 deletions

View file

@ -59,8 +59,22 @@ export default {
</div>
<calendar-heatmap
:locale="locale"
:no-data-text="locale.no_contributions"
:tooltip-unit="locale.contributions"
:no-data-text="locale.contributions_zero"
:tooltip-formatter="
(v) =>
locale.contributions_format
.replace(
'{contributions}',
`<b>${v.count} ${
v.count === 1
? locale.contributions_one
: locale.contributions_few
}</b>`
)
.replace('{month}', locale.months[v.date.getMonth()])
.replace('{day}', v.date.getDate())
.replace('{year}', v.date.getFullYear())
"
:end-date="endDate"
:values="values"
:range-color="colorRange"

View file

@ -18,13 +18,14 @@ export function initHeatmap() {
return {date: new Date(v), count: heatmap[v]};
});
// last heatmap tooltip localization attempt https://github.com/go-gitea/gitea/pull/24131/commits/a83761cbbae3c2e3b4bced71e680f44432073ac8
const locale = {
months: new Array(12).fill().map((_, idx) => translateMonth(idx)),
days: new Array(7).fill().map((_, idx) => translateDay(idx)),
contributions: 'contributions',
contributions_in_the_last_12_months: el.getAttribute('data-locale-total-contributions'),
no_contributions: el.getAttribute('data-locale-no-contributions'),
contributions_zero: el.getAttribute('data-locale-contributions-zero'),
contributions_format: el.getAttribute('data-locale-contributions-format'),
contributions_one: el.getAttribute('data-locale-contributions-one'),
contributions_few: el.getAttribute('data-locale-contributions-few'),
more: el.getAttribute('data-locale-more'),
less: el.getAttribute('data-locale-less'),
};