1010
1111angular . module ( 'ui.calendar' , [ ] )
1212 . constant ( 'uiCalendarConfig' , { } )
13- . controller ( 'uiCalendarCtrl' , [ '$scope' , '$timeout' , function ( $scope , $timeout ) {
13+ . controller ( 'uiCalendarCtrl' , [ '$scope' , '$timeout' , '$locale' , function ( $scope , $timeout , $locale ) {
1414
1515 var sourceSerialId = 1 ,
1616 eventSerialId = 1 ,
@@ -165,26 +165,31 @@ angular.module('ui.calendar', [])
165165
166166 return config ;
167167 } ;
168- } ] )
169- . directive ( 'uiCalendar' , [ 'uiCalendarConfig' , '$locale' , function ( uiCalendarConfig , $locale ) {
170- // Configure to use locale names by default
171- var tValues = function ( data ) {
172- // convert {0: "Jan", 1: "Feb", ...} to ["Jan", "Feb", ...]
173- var r , k ;
174- r = [ ] ;
175- for ( k in data ) {
176- r [ k ] = data [ k ] ;
168+
169+ this . getLocaleConfig = function ( fullCalendarConfig ) {
170+ if ( ! fullCalendarConfig . lang || fullCalendarConfig . useNgLocale ) {
171+ // Configure to use locale names by default
172+ var tValues = function ( data ) {
173+ // convert {0: "Jan", 1: "Feb", ...} to ["Jan", "Feb", ...]
174+ var r , k ;
175+ r = [ ] ;
176+ for ( k in data ) {
177+ r [ k ] = data [ k ] ;
178+ }
179+ return r ;
180+ } ;
181+ var dtf = $locale . DATETIME_FORMATS ;
182+ return {
183+ monthNames : tValues ( dtf . MONTH ) ,
184+ monthNamesShort : tValues ( dtf . SHORTMONTH ) ,
185+ dayNames : tValues ( dtf . DAY ) ,
186+ dayNamesShort : tValues ( dtf . SHORTDAY )
187+ } ;
177188 }
178- return r ;
189+ return { } ;
179190 } ;
180- var dtf = $locale . DATETIME_FORMATS ;
181- uiCalendarConfig = angular . extend ( {
182- monthNames : tValues ( dtf . MONTH ) ,
183- monthNamesShort : tValues ( dtf . SHORTMONTH ) ,
184- dayNames : tValues ( dtf . DAY ) ,
185- dayNamesShort : tValues ( dtf . SHORTDAY )
186- } , uiCalendarConfig || { } ) ;
187-
191+ } ] )
192+ . directive ( 'uiCalendar' , [ 'uiCalendarConfig' , function ( uiCalendarConfig ) {
188193 return {
189194 restrict : 'A' ,
190195 scope : { eventSources :'=ngModel' , calendarWatchEvent : '&' } ,
@@ -203,8 +208,11 @@ angular.module('ui.calendar', [])
203208
204209 fullCalendarConfig = controller . getFullCalendarConfig ( calendarSettings , uiCalendarConfig ) ;
205210
211+ var localeFullCalendarConfig = controller . getLocaleConfig ( fullCalendarConfig ) ;
212+ angular . extend ( localeFullCalendarConfig , fullCalendarConfig ) ;
213+
206214 options = { eventSources : sources } ;
207- angular . extend ( options , fullCalendarConfig ) ;
215+ angular . extend ( options , localeFullCalendarConfig ) ;
208216
209217 var options2 = { } ;
210218 for ( var o in options ) {
0 commit comments