-
-
Save phene/b7eafbcfc79a4bda2a4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/public/javascripts/i18n.js b/public/javascripts/i18n.js | |
index 0ac90f2..fc94375 100644 | |
--- a/public/javascripts/i18n.js | |
+++ b/public/javascripts/i18n.js | |
@@ -302,24 +302,29 @@ I18n.toPercentage = function(number, options) { | |
}; | |
I18n.pluralize = function(count, scope, options) { | |
- var translation = this.lookup(scope, options); | |
- | |
- var message; | |
+ var translation = this.lookup(scope, options); | |
options = this.prepareOptions(options); | |
- options["count"] = count.toString(); | |
- | |
- switch(Math.abs(count)) { | |
- case 0: | |
- message = translation["zero"] || translation["none"] || translation["other"] || this.missingTranslation(scope, "zero"); | |
- break; | |
- case 1: | |
- message = translation["one"] || this.missingTranslation(scope, "one");; | |
- break; | |
- default: | |
- message = translation["other"] || this.missingTranslation(scope, "other");; | |
+ | |
+ try { | |
+ var message; | |
+ options["count"] = count.toString(); | |
+ | |
+ switch(Math.abs(count)) { | |
+ case 0: | |
+ message = translation["zero"] || translation["none"] || translation["other"] || this.missingTranslation(scope, "zero"); | |
+ break; | |
+ case 1: | |
+ message = translation["one"] || this.missingTranslation(scope, "one");; | |
+ break; | |
+ default: | |
+ message = translation["other"] || this.missingTranslation(scope, "other");; | |
+ } | |
+ | |
+ return this.interpolate(message, options); | |
+ | |
+ } catch(err) { | |
+ return this.missingTranslation(scope); | |
} | |
- | |
- return this.interpolate(message, options); | |
}; | |
I18n.missingTranslation = function() { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment