Localize time units on activity heatmap (#21570)
Previously, the months and days were hardcoded into English * Closes #15541 ## Screenshots ### English  ### German  ### Spanish  ### Italian  ### Portuguese This one has a bit of overflow  Signed-off-by: Yarden Shoham <hrsi88@gmail.com> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
76e9a4f701
commit
125e3e3d66
4 changed files with 51 additions and 7 deletions
|
@ -70,3 +70,18 @@ export function prettyNumber(num, locale = 'en-US') {
|
|||
export function parseUrl(str) {
|
||||
return new URL(str, str.startsWith('http') ? undefined : window.location.origin);
|
||||
}
|
||||
|
||||
// return current locale chosen by user
|
||||
function getCurrentLocale() {
|
||||
return document.documentElement.lang;
|
||||
}
|
||||
|
||||
// given a month (0-11), returns it in the documents language
|
||||
export function translateMonth(month) {
|
||||
return new Date(Date.UTC(2022, month, 12)).toLocaleString(getCurrentLocale(), {month: 'short'});
|
||||
}
|
||||
|
||||
// given a weekday (0-6, Sunday to Saturday), returns it in the documents language
|
||||
export function translateDay(day) {
|
||||
return new Date(Date.UTC(2022, 7, day)).toLocaleString(getCurrentLocale(), {weekday: 'short'});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue