bevacqua / rome

:calendar: Customizable date (and time) picker. Opt-in UI, no jQuery!
https://bevacqua.github.io/rome
MIT License
2.91k stars 223 forks source link

How to localize names of days and moths? #218

Open AndyZotya opened 1 year ago

AndyZotya commented 1 year ago

I still don't understand how to localize a calendar. Could you provide an example?

AndyZotya commented 1 year ago

This code working: rome(rome_d, { weekStart: 1, initialValue: '2023-04-11 00:00', time: false, weekdayFormat: ['Нд','Пн','Вт','ср','Чт','Пт','Сб'] }); But this don't rome(rome_d, { weekStart: 1, initialValue: '2023-04-11 00:00', time: false, weekdayFormat: ['Нд','Пн','Вт','ср','Чт','Пт','Сб'], monthFormat: ['Січень','Лютий','Березень','Квітень','Травень','Червень','Липень','Серпень','Вересень','Жовтень','Листопад','Грудень'] });

Aiderlei commented 7 months ago

You can basically do something like this:

let moment = require('moment')
import rome from '@bevacqua/rome/dist/rome.js'
import '@bevacqua/rome/dist/rome.css'

let locale = document.body.dataset.locale
moment.locale(locale)
rome.use(moment)

const datePicker = rome(element, { time: false })

Note that I did not package the code as a component for demonstration purpose. You can adjust it to your setup.