In Spree (Rails E-commerce App) what is the preferred way to limit locales?
-
19-09-2019 - |
Question
I only want to support German and English for a starter.
As I see it I can easily limit this in the spree core locales.rb
, or in the localization extension by simply deleting the locale files.
But this doesn't quite seem right. I would like to configure it form my site extension, without basically forking spree. Can someone tell me how I can set AVAILABLE_LOCALES from there?
Solution
You can change the AVAILABLE_LOCALES in config/initializers/locales.rb. Obviously usually it's not necessary to have too many localisations. Simply just change the code, which by default collects all locales available.
You might want something like this:
require 'spree/extension'
all_locale_paths = Spree::ExtensionLoader.load_extension_roots.dup << SPREE_ROOT
AVAILABLE_LOCALES = {'en-GB'=>'English', 'de'=>'Deutsch'}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow