views:

311

answers:

1

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?

+2  A: 

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'}
fifigyuri
I did it this way, appending to the end of the locales.rb: AVAILABLE_LOCALES.delete_if {|k,| !k.match(/^(de|en)/) }
hurikhan77