From b05d8f6ff8774e0d8aaf8f6638ccdee2a7739ac4 Mon Sep 17 00:00:00 2001 From: agrajaghh Date: Wed, 19 Oct 2016 17:29:03 +0200 Subject: [PATCH] getPlural: throw error if n is no number --- src/catalog.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/catalog.js b/src/catalog.js index fbc3688..af608de 100644 --- a/src/catalog.js +++ b/src/catalog.js @@ -258,6 +258,10 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, ge * @description Translate a plural string with the given context. */ getPlural: function (n, string, stringPlural, scope, context) { + if (typeof n !== 'number' && typeof n !== 'undefined') { + throw new Error('n has to be a number. Found ' + typeof n + ' instead.'); + } + var fallbackLanguage = gettextFallbackLanguage(this.currentLanguage); string = this.getStringFormFor(this.currentLanguage, string, n, context) || this.getStringFormFor(fallbackLanguage, string, n, context) ||