Last active
May 11, 2021 10:37
-
-
Save edisdev/b67597b55c5edd3dd12527e55b43f7dc to your computer and use it in GitHub Desktop.
Ay ve Günlerin Javascript İle Dil Ayarı İçin Ufak Bir Yöntem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calendarTranslation(lang) { | |
const currentYear = new Date().getFullYear() | |
const months = Array.from({length: 12}, function(_, index) { | |
let name = new Date(currentYear, index).toLocaleString(lang, { month: 'long' }) | |
return ({index, name }) | |
}) | |
const days = Array.from({length: 7}, function (_, index) { | |
let name = new Date(currentYear, '00', index).toLocaleString(lang, { weekday: 'long' }) | |
let order = new Date(currentYear, '00', index).getDay() | |
return ({ name, order }) | |
}) | |
return { | |
months, | |
days | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment