This is a proof of concept for what could become a multi-lingual Spree plugin.
Warning: code quality is so-so (could even be poor). Just wanted to put out something before Spreeconf so we could discuss and maybe hack around it.
- Spree 1.0.X
- Rails 3.1.X
Add gem to your Gemfile:
gem "spree_multi_lingual", :git => "email@example.com:jipiboily/spree_multi_lingual.git"
Run Bundler bundle install
Add an initializer file and set SpreeMultiLingual.languages to an array containing the languages you support.
# config/initializers/spree_multi_lingual.rb SpreeMultiLingual.languages = ["fr", "en", "es"] # Add your own locales here
Copy migrations bundle exec rake spree_multi_lingual:install:migrations
Run migrations bundle exec rake db:migrate
//= require admin/spree_multi_lingual
On views where there is translated fields, there should be a dropdown to switch currently edited locale.
What is translated?
For now, only products name, description, meta description and meta keywords are translated.
there is no fallback of default language for now!
It uses Globalize3, easy_globalize3_accessors and routing-filter. Thanks to Tomash that told me about those two awesome gems: easy_globalize3_accessors and routing-filter.
- Add tests
- Capybara (selenium driver)
- Add things to translate:
- Option types
- Option values
- Alt text on images
- Dropdown or something to change locale
- Rake task for store that already have users
Testing (not used as of now: shame)
Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
$ bundle $ bundle exec rake test app $ bundle exec rspec spec
Copyright (c) 2012 Jean-Philippe Boily, released under the New BSD License