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

I18n::InvalidLocale error when :en is not included in config.i18n.available_locales #70

Open
BarnabeD opened this issue Nov 5, 2024 · 1 comment

Comments

@BarnabeD
Copy link

BarnabeD commented Nov 5, 2024

It's not a bug, but possibly a new feature! 😄

My issue:

I'm building a French-only application with solid_errors and I get this error I18n::InvalidLocale.
My application will be available in different languages, but for now, the only locale available is :fr.
In solid_errors the locale is forced in the ErrorsController by around_action :force_english_locale!

I patched it with this initializer, added the locale keys to my locale file and everything works fine:

Rails.application.config.to_prepare do
  SolidErrors::ErrorsController.class_eval do
    skip_around_action :force_english_locale!
  end
end

My suggestions:

I think about two solutions :

  • Changing the hardcoded :en locale and rely on the application's default locale.
  • Add the SolidErrors configuration to manually set the locale with :en as fallback.

Let me know if this feature catches your attention, I'm ready to help.

@fractaledmind
Copy link
Owner

Hmm... You are right, I don't love this. That change originated with PR #36 which was added to avoid missing translations:

because the engine is using the custom "datetime.distance_in_words.short" translation set, which doesn't exist on rails-i18n.

So, what we need, I think, is a localization flexible approach to the views. But I would love to make the localization story in Solid Errors much better, and I am happy to see your take on it.

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