This is the Internationalization project for Spree Commerce
See the official Internationalization documentation for more details.
To install, simply add the Gem to your Gemfile:
- Add the following to your Gemfile
gem 'spree_i18n', :git => 'git://github.com/spree/spree_i18n.git'
- Run
bundle install
We've added support for translating models. The feature uses the globalize3 gem to localize model data. So far the following models are translatable:
Product, Promotion, OptionType, Taxonomy, Taxon and Property.
Try it out! Point to the translate-models branch:
gem 'spree_i18n', :git => 'git://github.com/spree/spree_i18n.git', :branch => 'translate-models'
You can use the generator to install migrations and append spree_i18n assets to your app spree manifest file.
rails g spree_i18n:install
This will insert this lines on your spree manifest files:
app/assets/javascripts/admin/all.js
//= require admin/spree_i18n
app/assets/javascripts/store/all.js
//= require store/spree_i18n
app/assets/stylesheets/admin/all.css
*= require admin/spree_i18n
Start you server and you should see a TRANSLATIONS link or a flag icon on each admin section that supports this feature.
The extension contains two configs that allow users to customize which locales should be displayed as options on the translation forms and which should be listed to customers on the frontend. You can set them on an initializer. e.g.
# displayed on translation forms
SpreeI18n::Config.available_locales = [:en, :es, :'pt-BR']
# displayed on frontend select box
SpreeI18n::Config.supported_locales = [:en, :'pt-BR']
ps. please use symbols, not strings. e.g. :'pt-BR' not just 'pt-BR'. Otherwise you may get unexpected errors
Or if you prefer they're also available on the admin UI general settings section.
Every record needs to have a translation. If by any chance you remove spree_i18n
from your Gemfile, add some records and then add spree_i18n gem back you might get
errors like undefined method for nilClass
because Globalize will try fetch
translations that do not exist.
If you would like to run the tests of this project, follow these steps:
- Clone this repo using
git clone git://github.com/spree/spree_i18n
- Change into the directory and run
bundle exec rake test_app
to generate a dummy application. - Run
bundle exec rspec spec
to run the tests.
A ruby translation project managed on Locale that's open to all!
- Edit the translations directly on the spree_i18n project on Locale.
- That's it!
- The maintainer will then pull translations from the Locale project and push to Github.
Happy translating!
First, make sure you have created the temporary directory used by the localeapp gem during pushes, etc.
mkdir -p .localeapp/locales
Next, if you're one of the community members with the necessary credentials to update the default locale file on localeapp.com then you can do so with the following command.
localeapp --api-key=YOURAPIKEYHERE push ../spree/core/config/locales/en.yml