@@ -3,15 +3,14 @@ import { WEEKDAYS, IFormattingOptions, IFormattingViews, IViewDateChangeEventArg
33import { ControlValueAccessor } from '@angular/forms' ;
44import { DateRangeDescriptor } from '../core/dates' ;
55import { noop , Subject } from 'rxjs' ;
6- import { isDate , isEqual , PlatformUtil } from '../core/utils' ;
6+ import { getLocaleFirstDayOfWeek , isDate , isEqual , PlatformUtil } from '../core/utils' ;
77import { CalendarResourceStringsEN , ICalendarResourceStrings } from '../core/i18n/calendar-resources' ;
88import { DateTimeUtil } from '../date-common/util/date-time.util' ;
9- import { getLocaleFirstDayOfWeek } from "@angular/common" ;
109import { getCurrentResourceStrings } from '../core/i18n/resources' ;
1110import { KeyboardNavigationService } from './calendar.services' ;
1211import { getYearRange , isDateInRanges } from './common/helpers' ;
1312import { CalendarDay } from './common/model' ;
14- import { getI18nManager } from 'igniteui-i18n-core' ;
13+ import { getCurrentI18n , getI18nManager , ResourceChangeEventArgs } from 'igniteui-i18n-core' ;
1514
1615/** @hidden @internal */
1716@Directive ( {
@@ -290,13 +289,6 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
290289 public set locale ( value : string ) {
291290 this . _locale = value ;
292291
293- // if value is not a valid BCP 47 tag, set it back to _localeId
294- try {
295- getLocaleFirstDayOfWeek ( this . _locale ) ;
296- } catch ( e ) {
297- this . _locale = this . _localeId ;
298- }
299-
300292 // changing locale runtime needs to update the `weekStart` too, if `weekStart` is not explicitly set
301293 if ( ! this . weekStart ) {
302294 this . weekStart = getLocaleFirstDayOfWeek ( this . _locale ) ;
@@ -657,11 +649,12 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
657649 protected keyboardNavigation ?: KeyboardNavigationService ,
658650 protected cdr ?: ChangeDetectorRef ,
659651 ) {
660- this . locale = _localeId ;
652+ this . locale = getCurrentI18n ( ) || _localeId ;
661653 this . viewDate = this . viewDate ? this . viewDate : new Date ( ) ;
662654 this . initFormatters ( ) ;
663655
664- getI18nManager ( ) . onResourceChange ( ( ) => {
656+ getI18nManager ( ) . onResourceChange ( ( args : ResourceChangeEventArgs ) => {
657+ this . locale = args . newLocale ;
665658 this . _resourceStrings = getCurrentResourceStrings ( CalendarResourceStringsEN , false ) ;
666659 } ) ;
667660 }
0 commit comments