Module: Mobility

Defined in:
lib/mobility/plugins/store_based_fallbacks.rb

Overview

The default implementation in the Mobility gem requires fallbacks to be defined when booting the application. This patch allows to dynamically reconfigure translations fallbacks, by setting Mobility.store_based_fallbacks attribute. The implementation is based on the default fallbacks plugin, with some changes around fetching the list of fallbacks to be used. https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/fallbacks.rb

Defined Under Namespace

Modules: Plugins

Class Method Summary collapse

Class Method Details

.store_based_fallbacksObject

Request-scoped via RequestStore (like Mobility.locale), so one request's store fallbacks can't leak into the next request served by the same thread. Outside a request RequestStore degrades to plain per-thread storage; Spree::BaseMailer#with_store_locale restores the previous value around mail rendering.



16
17
18
# File 'lib/mobility/plugins/store_based_fallbacks.rb', line 16

def store_based_fallbacks
  RequestStore.store[:mobility_store_based_fallbacks] ||= I18n::Locale::Fallbacks.new
end

.store_based_fallbacks=(value) ⇒ Object



20
21
22
# File 'lib/mobility/plugins/store_based_fallbacks.rb', line 20

def store_based_fallbacks=(value)
  RequestStore.store[:mobility_store_based_fallbacks] = value
end