Skip to content

Localize time units on activity heatmap #21570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0479791
Localize time units on activity heatmap
yardenshoham Oct 23, 2022
9bbba06
Localize heatmap constants and tooltip
yardenshoham Oct 24, 2022
5cadb9d
Merge remote-tracking branch 'upstream/main' into localize-heatmap
yardenshoham Oct 24, 2022
57e4135
Add tests
yardenshoham Oct 24, 2022
2d01191
Destructure
yardenshoham Oct 24, 2022
95dd077
Merge remote-tracking branch 'upstream/main' into localize-heatmap
yardenshoham Oct 24, 2022
eba5ff3
Drop line
yardenshoham Oct 24, 2022
50092fc
Merge branch 'main' into localize-heatmap
yardenshoham Oct 25, 2022
d1a8a92
Rename `format` --> `translate`
yardenshoham Oct 25, 2022
fa30c07
Remove overhead
yardenshoham Oct 25, 2022
9e07322
Merge remote-tracking branch 'upstream/main' into localize-heatmap
yardenshoham Oct 25, 2022
d2d5081
Update web_src/js/utils.js
yardenshoham Oct 25, 2022
afaa731
Update web_src/js/utils.test.js
yardenshoham Oct 26, 2022
d44a422
Revert locale attempt
yardenshoham Oct 26, 2022
e54d70d
Merge branch 'main' into localize-heatmap
yardenshoham Oct 26, 2022
55b2f28
Lint
yardenshoham Oct 26, 2022
8775a5a
Merge remote-tracking branch 'upstream/main' into localize-heatmap
yardenshoham Oct 26, 2022
2557f99
Merge branch 'main' into localize-heatmap
lunny Oct 27, 2022
51f400f
Merge branch 'main' into localize-heatmap
lunny Oct 27, 2022
caaee20
Trigger build
yardenshoham Oct 27, 2022
607473b
Merge branch 'main' into localize-heatmap
lunny Oct 28, 2022
a7a75d2
Merge branch 'main' into localize-heatmap
lunny Oct 28, 2022
1a4fe52
Merge branch 'main' into localize-heatmap
lunny Oct 28, 2022
2b416cc
Merge branch 'main' into localize-heatmap
yardenshoham Oct 28, 2022
6cd227c
Merge branch 'main' into localize-heatmap
techknowlogick Oct 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion web_src/js/components/ActivityHeatmap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</template>
<script>
import {CalendarHeatmap} from 'vue3-calendar-heatmap';
import heatmapLocale from '../features/heatmap-locale.js';

export default {
name: 'ActivityHeatmap',
Expand All @@ -39,7 +40,7 @@ export default {
locale: {
contributions: 'contributions',
no_contributions: 'No contributions',
},
...heatmapLocale},
}),
computed: {
sum() {
Expand Down
14 changes: 14 additions & 0 deletions web_src/js/features/heatmap-locale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const {lang} = document.documentElement;

// given a month (0-11), returns it in the documents language
const formatMonth = (month) => new Date(Date.UTC(2022, month, 12)).toLocaleString(lang, {month: 'short'});

// given a weekday (0-6, Sunday to Saturday), returns it in the documents language
const formatDay = (day) => new Date(Date.UTC(2022, 7, day)).toLocaleString(lang, {weekday: 'short'});

const months = new Array(12).fill().map((_, idx) => formatMonth(idx));
const days = new Array(7).fill().map((_, idx) => formatDay(idx));

const heatmapLocale = {months, days};

export default heatmapLocale;