mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Don't cache translations in development mode
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
module JsLocaleHelper
|
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 ||= HashWithIndifferentAccess.new
|
||||||
@loaded_translations[locale] ||= begin
|
@loaded_translations[locale] ||= begin
|
||||||
locale_str = locale.to_s
|
locale_str = locale.to_s
|
||||||
@@ -78,7 +82,7 @@ module JsLocaleHelper
|
|||||||
site_locale = SiteSetting.default_locale.to_sym
|
site_locale = SiteSetting.default_locale.to_sym
|
||||||
|
|
||||||
if Rails.env.development?
|
if Rails.env.development?
|
||||||
translations = load_translations(locale_sym)
|
translations = load_translations(locale_sym, force: true)
|
||||||
else
|
else
|
||||||
if locale_sym == :en
|
if locale_sym == :en
|
||||||
translations = load_translations(locale_sym)
|
translations = load_translations(locale_sym)
|
||||||
@@ -115,7 +119,7 @@ module JsLocaleHelper
|
|||||||
|
|
||||||
def self.moment_format_function(name)
|
def self.moment_format_function(name)
|
||||||
format = I18n.t("dates.#{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
|
end
|
||||||
|
|
||||||
def self.moment_locale(locale_str)
|
def self.moment_locale(locale_str)
|
||||||
|
|||||||
Reference in New Issue
Block a user