mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
BUGFIX: fallback to en translation when interpolation is missing
This commit is contained in:
parent
8167cefe36
commit
17f75bbe92
@ -13,12 +13,20 @@ module I18n
|
|||||||
def translate(*args)
|
def translate(*args)
|
||||||
@cache ||= LruRedux::ThreadSafeCache.new(LRU_CACHE_SIZE)
|
@cache ||= LruRedux::ThreadSafeCache.new(LRU_CACHE_SIZE)
|
||||||
found = true
|
found = true
|
||||||
k = [args,config.locale,config.backend.object_id]
|
k = [args, config.locale, config.backend.object_id]
|
||||||
t = @cache.fetch(k){found=false}
|
t = @cache.fetch(k) { found = false }
|
||||||
unless found
|
unless found
|
||||||
t = @cache[k] = translate_no_cache(*args).freeze
|
begin
|
||||||
|
t = translate_no_cache(*args)
|
||||||
|
rescue MissingInterpolationArgument
|
||||||
|
options = args.last.is_a?(Hash) ? args.pop.dup : {}
|
||||||
|
options.merge!(locale: config.default_locale)
|
||||||
|
key = args.shift
|
||||||
|
t = translate_no_cache(key, options)
|
||||||
|
ensure
|
||||||
|
t = @cache[k] = t.freeze
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
t
|
t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user