Skip to content

Commit a17f9fd

Browse files
mmalerbajelbourn
authored andcommitted
docs(datepicker): explicitly mention i18n and warn people about pitfalls (#4598)
* docs(datepicker): explicitly mention i18n and warn people about pitfalls of using NativeDateAdapter
1 parent e8ab0da commit a17f9fd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/lib/datepicker/datepicker.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,14 @@ export class MyComponent implements AfterViewInit {
118118
}
119119
```
120120

121-
### Choosing a date implementation and date format settings
121+
### Internationalization
122+
In order to support internationalization, the datepicker supports customization of the following
123+
three pieces via injection:
124+
1. The date implementation that the datepicker accepts.
125+
2. The display and parse formats used by the datepicker.
126+
3. The message strings used in the datepicker's UI.
127+
128+
#### Choosing a date implementation and date format settings
122129
The datepicker was built to be date implementation agnostic. This means that it can be made to work
123130
with a variety of different date implementations. However it also means that developers need to make
124131
sure to provide the appropriate pieces for the datepicker to work with their chosen implementation.
@@ -148,6 +155,11 @@ export class MyComponent {
148155
}
149156
```
150157

158+
*Please note: `MdNativeDateModule` is based off of the functionality available in JavaScript's
159+
native `Date` object, and is thus not suitable for many locales. One of the biggest shortcomings of
160+
the native `Date` object is the inability to set the parse format. We highly recommend using a
161+
custom `DateAdapter` that works with the formatting/parsing library of your choice.*
162+
151163
#### Customizing the date implementation
152164
The datepicker does all of its interaction with date objects via the `DateAdapter`. Making the
153165
datepicker work with a different date implementation is as easy as extending `DateAdapter`, and
@@ -183,7 +195,7 @@ formats.
183195
export class MyApp {}
184196
```
185197

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

0 commit comments

Comments
 (0)