Skip to content

Commit ff27a93

Browse files
authored
docs(material/datepicker): Update close calendar label (#26738)
Previously, the close calendar label was not updating correctly when switching languages. This commit fixes that issue. Fixes: #25021
1 parent 8863885 commit ff27a93

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Inject} from '@angular/core';
1+
import {Component, Inject, OnInit} from '@angular/core';
22
import {
33
MAT_MOMENT_DATE_FORMATS,
44
MomentDateAdapter,
@@ -11,6 +11,7 @@ import {MatInputModule} from '@angular/material/input';
1111
import {MatFormFieldModule} from '@angular/material/form-field';
1212
import 'moment/locale/ja';
1313
import 'moment/locale/fr';
14+
import {MatDatepickerIntl} from '@angular/material/datepicker';
1415

1516
/** @title Datepicker with different locale */
1617
@Component({
@@ -34,15 +35,26 @@ import 'moment/locale/fr';
3435
standalone: true,
3536
imports: [MatFormFieldModule, MatInputModule, MatDatepickerModule, MatButtonModule],
3637
})
37-
export class DatepickerLocaleExample {
38+
export class DatepickerLocaleExample implements OnInit {
3839
constructor(
3940
private _adapter: DateAdapter<any>,
41+
private _intl: MatDatepickerIntl,
4042
@Inject(MAT_DATE_LOCALE) private _locale: string,
4143
) {}
4244

45+
ngOnInit() {
46+
this.updateCloseButtonLabel('カレンダーを閉じる');
47+
}
48+
4349
french() {
4450
this._locale = 'fr';
4551
this._adapter.setLocale(this._locale);
52+
this.updateCloseButtonLabel('Fermer le calendrier');
53+
}
54+
55+
updateCloseButtonLabel(label: string) {
56+
this._intl.closeCalendarLabel = label;
57+
this._intl.changes.next();
4658
}
4759

4860
getDateFormatString(): string {

0 commit comments

Comments
 (0)