Not compatible with FastGettext - request for string available locale support
Having the following FastGettext initializer:
# config/initializers/fast_gettext.rb
FastGettext.default_available_locales = %w[de en] # or %i for that matter
FastGettext.default_text_domain = 'app'
and the following Mobility initializer:
# config/initializers/mobility.rb
Mobility.configure do
plugins do
backend :column
active_record
reader
writer
backend_reader
query
cache
presence
locale_accessors # This line creates the problem
I'm getting the error :de is not a valid locale. I18n.available_locales returns: ["de", "en"]
Appearently, FastGettext sets the array to strings, whereas Mobility is looking for symbols.
Changing the FastGettext initializer to the following is a workaround:
# config/initializers/fast_gettext.rb
FastGettext.default_available_locales = %w[de en]
FastGettext.default_text_domain = 'app'
I18n.available_locales = %i[de en] # This line is needed
Note that changing FastGettext.default_available_locales to an array of symbols does not help.
Since Mobility is the first Gem that appears to have trouble with the locales being stored as Strings, I would like to propose, if adequate, to add String locales support to Mobility. Ideally, the gem would support both symbol and string keys for I18n.available_locales.
Best, Kalsan
I would like to propose, if adequate, to add String locales support to Mobility. Ideally, the gem would support both symbol and string keys for
I18n.available_locales.
That sounds reasonable, could you make a PR to do that?
@shioyama I added a pull request including tests. You might wanna review the PR manually anyways.