Skip to content

Commit 85864dc

Browse files
committed
fix(material/datepicker): add i18n strings
Add i18n strings for "Start Date" and "End Date". Add `formatYearRangeLabel` to format a year of dates in a screen reader friendly way (e.g. "2019 to 2020"). The existing method, `formatYearRange`, uses a dash character which does not read well on screen readers. These three new strings are not used in this commit. They will be used in future commits as aria labels and descriptions to fix accessibility bugs.
1 parent 2740e98 commit 85864dc

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/material/datepicker/datepicker-intl.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,19 @@ export class MatDatepickerIntl {
5151
/** A label for the 'switch to year view' button (used by screen readers). */
5252
switchToMultiYearViewLabel: string = 'Choose month and year';
5353

54-
/** Formats a range of years. */
54+
/** A label for the first date of a range of dates (used by screen readers). */
55+
startDateLabel?: string = 'Start date';
56+
57+
/** A label for the last date of a range of dates (used by screen readers). */
58+
endDateLabel?: string = 'End date';
59+
60+
/** Formats a range of years (used for visuals). */
5561
formatYearRange(start: string, end: string): string {
5662
return `${start} \u2013 ${end}`;
5763
}
64+
65+
/** Formats a label for a range of years (used by screen readers). */
66+
formatYearRangeLabel?(start: string, end: string): string {
67+
return `${start} to ${end}`;
68+
}
5869
}

tools/public_api_guard/material/datepicker.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,17 @@ export class MatDatepickerIntl {
525525
calendarLabel: string;
526526
readonly changes: Subject<void>;
527527
closeCalendarLabel: string;
528+
endDateLabel?: string;
528529
formatYearRange(start: string, end: string): string;
530+
formatYearRangeLabel?(start: string, end: string): string;
529531
nextMonthLabel: string;
530532
nextMultiYearLabel: string;
531533
nextYearLabel: string;
532534
openCalendarLabel: string;
533535
prevMonthLabel: string;
534536
prevMultiYearLabel: string;
535537
prevYearLabel: string;
538+
startDateLabel?: string;
536539
switchToMonthViewLabel: string;
537540
switchToMultiYearViewLabel: string;
538541
// (undocumented)

0 commit comments

Comments
 (0)