From 320e4a83ac52077fd5797217842d2470370cf76d Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 20 Aug 2015 12:03:43 -0400 Subject: [PATCH] FIX: Don't cache translations in development mode --- lib/js_locale_helper.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/js_locale_helper.rb b/lib/js_locale_helper.rb index 22f7ebb835f..af06c334092 100644 --- a/lib/js_locale_helper.rb +++ b/lib/js_locale_helper.rb @@ -1,6 +1,10 @@ module JsLocaleHelper - def self.load_translations(locale) + def self.load_translations(locale, opts=nil) + opts ||= {} + + @loaded_translations = nil if opts[:force] + @loaded_translations ||= HashWithIndifferentAccess.new @loaded_translations[locale] ||= begin locale_str = locale.to_s @@ -78,7 +82,7 @@ module JsLocaleHelper site_locale = SiteSetting.default_locale.to_sym if Rails.env.development? - translations = load_translations(locale_sym) + translations = load_translations(locale_sym, force: true) else if locale_sym == :en translations = load_translations(locale_sym) @@ -115,7 +119,7 @@ module JsLocaleHelper def self.moment_format_function(name) format = I18n.t("dates.#{name}") - result = "moment.fn.#{name.camelize(:lower)} = function(){ return this.format('#{format}'); };\n" + "moment.fn.#{name.camelize(:lower)} = function(){ return this.format('#{format}'); };\n" end def self.moment_locale(locale_str)