Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use DatePicker locale and localeUtils? #3621

Closed
nagylzs opened this issue Jun 24, 2019 · 1 comment · Fixed by #3635
Closed

How to use DatePicker locale and localeUtils? #3621

nagylzs opened this issue Jun 24, 2019 · 1 comment · Fixed by #3635

Comments

@nagylzs
Copy link

nagylzs commented Jun 24, 2019

The documentation on DatePicker does not tell what is localeUtils and how to use it.

https://blueprintjs.com/docs/versions/2/#datetime/datepicker

DatePicker already requires moment.js and moment.js already provides i18n. This is at the beginning of my project:


import moment from 'moment';
moment.locale('hu');

Some questions:

  1. Let's suppose that the user has already setup a global locale with moment.js (which is required by DatePicker anyway). Shouldn't DatePicker use this global locale by default?

  2. The documentation does not explain the localeUtils property. It just says that it is a "collection of functions that provide internationalization support.". I could look it up in the source code, but there is no implementation for it. Or at least, I could not find any. It would be very useful to create a default implementation that uses moment.js - since moment already provides the functions that are needed! It would be a very useful default implementation, e.g.:

const localeUtils = new MomentLocaleUtils("hu");
<DatePicker locale={localeUtils.locale} localeUtils={localeUtils} {...otherProps} />
@adidahiya
Copy link
Contributor

DatePicker and react-day-picker do not explicitly require moment.js, it is an optional dependency which you can use to implement the format/parse functions you supply as props to @blueprintjs/datetime components.

You can import localeUtils from react-day-picker. That's where we get the types for localeUtils. See:

import { LocaleUtils } from "react-day-picker/types/utils";

so you can use the same import in your project. I agree that the documentation around this could be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants