Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
fix(messageformat): add duck type check for numbers #789
Browse files Browse the repository at this point in the history
  • Loading branch information
knalli committed Apr 26, 2015
1 parent 98e8279 commit bbc1cbe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/service/messageformat-interpolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ function $translateMessageFormatInterpolation($translateSanitization, $cacheFact

// if given string wasn't interpolated yet, we do so now and never have to do it again
if (!interpolatedText) {

// Ensure explicit type if possible
// MessageFormat checks the actual type (i.e. for amount based conditions)
for (var key in interpolationParams) {
if (interpolationParams.hasOwnProperty(key)) {
// ensure number
var number = parseInt(interpolationParams[key], 10);
if (angular.isNumber(number) && ('' + number) === interpolationParams[key]) {
interpolationParams[key] = number;
}
}
}

interpolatedText = $mf.compile(string)(interpolationParams);
interpolatedText = $translateSanitization.sanitize(interpolatedText, 'text');

Expand Down

0 comments on commit bbc1cbe

Please sign in to comment.