dillidon/alerts-and-pickers

Support for L10n

geclick opened this issue · 0 comments

I needed to change de default locale to spanish in a DatePicker and I found no way to do this using alert.addDatePicker. I thought changing the device language it will work, but at least in simulator it didn't work. I didn't install the library with Cocoapods, so I added a modification to DatePickerViewController init

`required public init(mode: UIDatePicker.Mode, date: Date? = nil, minimumDate: Date? = nil, maximumDate: Date? = nil, action: Action?) {
super.init(nibName: nil, bundle: nil)
datePicker.datePickerMode = mode

    //changing to spanish only for date selection
   //so September 13, 2021 becomes 13 Septiembre 2021 
    if mode == .date{
        datePicker.locale = Locale(identifier: "es_ES")
    }
    
    datePicker.date = date ?? Date()
    datePicker.minimumDate = minimumDate
    datePicker.maximumDate = maximumDate
    self.action = action
}`

It would be nice if there were an option to set the locale of the picker