Skip to content

Datetime editing does not work for non english #3240

@grillermo

Description

@grillermo

I found that momentJS lowercase all strings. You can try on your browser

moment().format("dddd D MMMM YYYY HH:mm")

Or whatever format and that will set all datetime inputs to lower case.

The datetime parser on lib/rails_admin/support/datetime.rb method delocalize asumes all words are titleized. So when that method is called by parse_string it will return the same string, not having delocalized anything so when the DateTime.strptime is called it will receive a string in spanish or whatever and raise ArgumentError returning nil.

I fixed it by editing lib/rails_admin/support/datetime.rb delocalize method adding the titleize method.
image

How should i proceed?

** update **
To avoid having to maintain my own fork of rails admin i just added a js file on the edit action that changes moment to use custom Titleized translations

moment.updateLocale('es', {
  weekdays: 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
  months : 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions