From 88a9e1351052a90e028865686c4343466b6c8a5f Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 20 Jun 2013 12:47:43 -0400 Subject: [PATCH] Don't create globals in i18n.js --- app/assets/javascripts/locales/i18n.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/locales/i18n.js b/app/assets/javascripts/locales/i18n.js index 944c55d34..3e187afae 100644 --- a/app/assets/javascripts/locales/i18n.js +++ b/app/assets/javascripts/locales/i18n.js @@ -186,7 +186,7 @@ I18n.interpolate = function(message, options) { value = "[missing " + placeholder + " value]"; } - regex = new RegExp(placeholder.replace(/\{/gm, "\\{").replace(/\}/gm, "\\}")); + var regex = new RegExp(placeholder.replace(/\{/gm, "\\{").replace(/\}/gm, "\\}")); message = message.replace(regex, value); } @@ -469,14 +469,14 @@ I18n.toPercentage = function(number, options) { }; I18n.pluralizer = function(locale) { - pluralizer = this.pluralizationRules[locale]; + var pluralizer = this.pluralizationRules[locale]; if (pluralizer !== undefined) return pluralizer; return this.pluralizationRules["en"]; }; I18n.findAndTranslateValidNode = function(keys, translation) { - for (i = 0; i < keys.length; i++) { - key = keys[i]; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; if (this.isValidNode(translation, key)) return translation[key]; } return null; @@ -497,9 +497,9 @@ I18n.pluralize = function(count, scope, options) { options = this.prepareOptions(options); options.count = count.toString(); - pluralizer = this.pluralizer(this.currentLocale()); - key = pluralizer(Math.abs(count)); - keys = ((typeof key == "object") && (key instanceof Array)) ? key : [key]; + var pluralizer = this.pluralizer(this.currentLocale()); + var key = pluralizer(Math.abs(count)); + var keys = ((typeof key == "object") && (key instanceof Array)) ? key : [key]; message = this.findAndTranslateValidNode(keys, translation); if (message == null) message = this.missingTranslation(scope, keys[0]);