Skip to content
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Inject} from '@angular/core';
import {Component, Inject, OnInit} from '@angular/core';
import {
MAT_MOMENT_DATE_FORMATS,
MomentDateAdapter,
Expand All @@ -7,6 +7,7 @@ import {
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
import 'moment/locale/ja';
import 'moment/locale/fr';
import {MatDatepickerIntl} from '@angular/material/datepicker';

/** @title Datepicker with different locale */
@Component({
Expand All @@ -29,15 +30,26 @@ import 'moment/locale/fr';
{provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS},
],
})
export class DatepickerLocaleExample {
export class DatepickerLocaleExample implements OnInit {
constructor(
private _adapter: DateAdapter<any>,
private _intl: MatDatepickerIntl,
@Inject(MAT_DATE_LOCALE) private _locale: string,
) {}

ngOnInit() {
this.updateCloseButtonLabel('カレンダーを閉じる');
}

french() {
this._locale = 'fr';
this._adapter.setLocale(this._locale);
this.updateCloseButtonLabel('Fermer le calendrier');
}

updateCloseButtonLabel(label: string) {
this._intl.closeCalendarLabel = label;
this._intl.changes.next();
}

getDateFormatString(): string {
Expand Down