@@ -153,13 +153,20 @@ var timerModule = angular.module('timer', [])
153
153
$scope . months = Math . floor ( ( ( $scope . millis / ( 3600000 ) ) / 24 / 30 ) % 12 ) ;
154
154
$scope . years = Math . floor ( ( $scope . millis / ( 3600000 ) ) / 24 / 365 ) ;
155
155
}
156
- // plural - singular unit decision
157
- $scope . secondsS = ( $scope . seconds === 1 || $scope . seconds === 0 ) ? '' : 's' ;
158
- $scope . minutesS = ( $scope . minutes === 1 || $scope . minutes === 0 ) ? '' : 's' ;
159
- $scope . hoursS = ( $scope . hours === 1 || $scope . hours === 0 ) ? '' : 's' ;
160
- $scope . daysS = ( $scope . days === 1 || $scope . days === 0 ) ? '' : 's' ;
161
- $scope . monthsS = ( $scope . months === 1 || $scope . months === 0 ) ? '' : 's' ;
162
- $scope . yearsS = ( $scope . years === 1 || $scope . years === 0 ) ? '' : 's' ;
156
+ // plural - singular unit decision (old syntax, for backwards compatibility and English only)
157
+ $scope . secondsS = ( $scope . seconds === 1 ) ? '' : 's' ;
158
+ $scope . minutesS = ( $scope . minutes === 1 ) ? '' : 's' ;
159
+ $scope . hoursS = ( $scope . hours === 1 ) ? '' : 's' ;
160
+ $scope . daysS = ( $scope . days === 1 ) ? '' : 's' ;
161
+ $scope . monthsS = ( $scope . months === 1 ) ? '' : 's' ;
162
+ $scope . yearsS = ( $scope . years === 1 ) ? '' : 's' ;
163
+ // new plural-singular unit decision functions (for custom units and multilingual support)
164
+ $scope . secondUnit = function ( singleSecond , pluralSecond ) { if ( $scope . seconds === 1 ) { return singleSecond } return pluralSecond } ;
165
+ $scope . minuteUnit = function ( singleMinute , pluralMinute ) { if ( $scope . minutes === 1 ) { return singleMinute } return pluralMinute } ;
166
+ $scope . hourUnit = function ( singleHour , pluralHour ) { if ( $scope . hours === 1 ) { return singleHour } return pluralHour } ;
167
+ $scope . dayUnit = function ( singleDay , pluralDay ) { if ( $scope . days === 1 ) { return singleDay } return pluralDay } ;
168
+ $scope . monthUnit = function ( singleMonth , pluralMonth ) { if ( $scope . months === 1 ) { return singleMonth } return pluralMonth } ;
169
+ $scope . yearUnit = function ( singleYear , pluralYear ) { if ( $scope . years === 1 ) { return singleYear } return pluralYear } ;
163
170
//add leading zero if number is smaller than 10
164
171
$scope . sseconds = $scope . seconds < 10 ? '0' + $scope . seconds : $scope . seconds ;
165
172
$scope . mminutes = $scope . minutes < 10 ? '0' + $scope . minutes : $scope . minutes ;
0 commit comments