Search code examples
reactjsdatepickermomentjsblueprintjs

setting locale in blueprintjs datetime react component


I'm trying to set the locale of blueprintjs DateRangeInput. The docs state that the Component uses Moment.js for localisation. So I tried to set locale="de", but the language is English still. Any ideas what is missing to get a translated date input?

I'm fairly new to React programming so I can't be sure that it has nothing to do with my React skills, even tho passing the props seems quite right to me.

<DateRangeInput
    locale={"de"}
    value={dates}
    onChange={...}
/>

Solution

  • try adding this import "moment/locale/de" to the top of the file

    i think blueprint uses new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/) to remove the locales from moment which is pretty common since moment is really large.

    if that doesn't work try adding this to your webpack plugins

    new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /de/)