mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-18 23:50:23 +00:00
feat(locale): add getPluralCat function
This commit is contained in:
parent
3ba90003b4
commit
0da4902e9d
2 changed files with 15 additions and 0 deletions
|
|
@ -58,6 +58,13 @@ angularServiceInject('$locale', function() {
|
|||
shortDate: 'M/d/yy',
|
||||
mediumTime: 'h:mm:ss a',
|
||||
shortTime: 'h:mm a'
|
||||
},
|
||||
|
||||
pluralCat: function(num) {
|
||||
if (num === 1) {
|
||||
return 'one';
|
||||
}
|
||||
return 'other';
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,5 +36,13 @@ describe('$locale', function() {
|
|||
expect(datetime.MONTH.length).toBe(12);
|
||||
expect(datetime.AMPMS.length).toBe(2);
|
||||
});
|
||||
|
||||
|
||||
it('should return correct plural types', function() {
|
||||
expect($locale.pluralCat(-1)).toBe('other');
|
||||
expect($locale.pluralCat(0)).toBe('other');
|
||||
expect($locale.pluralCat(2)).toBe('other');
|
||||
expect($locale.pluralCat(1)).toBe('one');
|
||||
})
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue