diff --git a/app/assets/javascripts/discourse.js b/app/assets/javascripts/discourse.js index 094c4e9bfc1..36d5edfa2ed 100644 --- a/app/assets/javascripts/discourse.js +++ b/app/assets/javascripts/discourse.js @@ -248,4 +248,3 @@ Discourse = Ember.Application.createWithMixins(Discourse.Ajax, { }); Discourse.Router = Discourse.Router.reopen({ location: 'discourse_location' }); - diff --git a/app/assets/javascripts/env.js b/app/assets/javascripts/env.js index 98996e8c05a..a8781abcb8e 100644 --- a/app/assets/javascripts/env.js +++ b/app/assets/javascripts/env.js @@ -8,5 +8,3 @@ window.ENV = { window.Discourse = {}; Discourse.SiteSettings = {}; - - diff --git a/app/assets/javascripts/locales/i18n.js b/app/assets/javascripts/locales/i18n.js index 3e187afae73..d8591f32715 100644 --- a/app/assets/javascripts/locales/i18n.js +++ b/app/assets/javascripts/locales/i18n.js @@ -60,8 +60,7 @@ I18n.locale = null; // Set the placeholder format. Accepts `{{placeholder}}` and `%{placeholder}`. I18n.PLACEHOLDER = /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm; -I18n.fallbackRules = { -}; +I18n.fallbackRules = {}; I18n.pluralizationRules = { en: function (n) { @@ -207,7 +206,7 @@ I18n.translate = function(scope, options) { } else { return this.interpolate(translation, options); } - } catch(err) { + } catch (error) { return this.missingTranslation(scope); } }; @@ -485,15 +484,9 @@ I18n.findAndTranslateValidNode = function(keys, translation) { I18n.pluralize = function(count, scope, options) { var translation; - try { - translation = this.lookup(scope, options); - } catch (error) {} + try { translation = this.lookup(scope, options); } catch (error) {} + if (!translation) { return this.missingTranslation(scope); } - if (!translation) { - return this.missingTranslation(scope); - } - - var message; options = this.prepareOptions(options); options.count = count.toString(); @@ -501,24 +494,16 @@ I18n.pluralize = function(count, scope, options) { var key = pluralizer(Math.abs(count)); var keys = ((typeof key == "object") && (key instanceof Array)) ? key : [key]; - message = this.findAndTranslateValidNode(keys, translation); + var message = this.findAndTranslateValidNode(keys, translation); if (message == null) message = this.missingTranslation(scope, keys[0]); return this.interpolate(message, options); }; -I18n.missingTranslation = function() { - var message = '[missing "' + this.currentLocale() - , count = arguments.length - ; - - for (var i = 0; i < count; i++) { - message += "." + arguments[i]; - } - - message += '" translation]'; - - return message; +I18n.missingTranslation = function(scope, key) { + var message = '[' + this.currentLocale() + "." + scope; + if (key) { message += "." + key; } + return message + ']'; }; I18n.currentLocale = function() { diff --git a/app/views/common/_discourse_javascript.html.erb b/app/views/common/_discourse_javascript.html.erb index 151927422e7..63ca917259a 100644 --- a/app/views/common/_discourse_javascript.html.erb +++ b/app/views/common/_discourse_javascript.html.erb @@ -7,23 +7,16 @@ 'defer/google_diff_match_patch': <%= asset_path('defer/google_diff_match_patch.js').inspect.html_safe %> }; - var assetPath = function(asset){ - return map[asset]; - }; - - return assetPath; + return function(asset){ return map[asset]; }; })(); - diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 473ac8ab129..0ef90532ce4 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,6 +11,7 @@ + <%= javascript_include_tag "preload_store" %> <%= javascript_include_tag "locales/#{I18n.locale}" %>