Skip to content

docs(datepicker): explicitly mention i18n and warn people about pitfa… #4598

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

Merged
merged 2 commits into from
May 18, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/lib/datepicker/datepicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ export class MyComponent implements AfterViewInit {
}
```

### Choosing a date implementation and date format settings
### Internationalization
In order to support internationalization, the datepicker supports customization of the following
three pieces via injection:
1. The date implementation that the datepicker accepts.
2. The display and parse formats used by the datepicker.
3. The message strings used in the datepicker's UI.

#### Choosing a date implementation and date format settings
The datepicker was built to be date implementation agnostic. This means that it can be made to work
with a variety of different date implementations. However it also means that developers need to make
sure to provide the appropriate pieces for the datepicker to work with their chosen implementation.
Expand Down Expand Up @@ -148,6 +155,12 @@ export class MyComponent {
}
```

*Please note: `MdNativeDateModule` is based off of the functionality available in JavaScript's
native Date object, and is thus not suitable for many locales. One of the biggest shortcomings of
the native Date object is the inability to set the parse format. We highly recommend writing a
custom `DateAdapter` that works with the formatting/parsing library of your choice, or waiting for
the official Moment.js module.*
Copy link
Member

@jelbourn jelbourn May 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rephrase this to not convey that Moment is the "official" way of doing i18n, but just that we plan on making a moment adapter available as a convenience

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just removed the moment.js reference here since it's already mentioned in a few other places that we plan to make that


#### Customizing the date implementation
The datepicker does all of its interaction with date objects via the `DateAdapter`. Making the
datepicker work with a different date implementation is as easy as extending `DateAdapter`, and
Expand Down Expand Up @@ -183,7 +196,7 @@ formats.
export class MyApp {}
```

### Localizing labels and messages
#### Localizing labels and messages
The various text strings used by the datepicker are provided through `MdDatepickerIntl`.
Localization of these messages can be done by providing a subclass with translated values in your
application root module.
Expand Down