Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with FastGettext - request for string available locale support #605

Closed
kalsan opened this issue Feb 22, 2023 · 2 comments
Closed

Comments

@kalsan
Copy link
Contributor

kalsan commented Feb 22, 2023

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

@shioyama
Copy link
Owner

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?

@kalsan
Copy link
Contributor Author

kalsan commented Apr 6, 2023

@shioyama I added a pull request including tests. You might wanna review the PR manually anyways.

shioyama pushed a commit that referenced this issue Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants