aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDi Peng2011-08-24 11:00:18 -0700
committerIgor Minar2011-08-30 02:11:08 -0700
commit0da4902e9db4f6f494b8be74c41f21d5e5520b79 (patch)
tree1118b1268c975bdb339b1e90549cb3222f539bbf
parent3ba90003b415542501a0732e09e1271bbd830eff (diff)
downloadangular.js-0da4902e9db4f6f494b8be74c41f21d5e5520b79.tar.bz2
feat(locale): add getPluralCat function
-rw-r--r--src/service/locale.js7
-rw-r--r--test/service/localeSpec.js8
2 files changed, 15 insertions, 0 deletions
diff --git a/src/service/locale.js b/src/service/locale.js
index e94c2100..069a691e 100644
--- a/src/service/locale.js
+++ b/src/service/locale.js
@@ -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';
}
};
});
diff --git a/test/service/localeSpec.js b/test/service/localeSpec.js
index 048cf5b5..4be49275 100644
--- a/test/service/localeSpec.js
+++ b/test/service/localeSpec.js
@@ -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');
+ })
});