Skip to content

VitaliyAdamkov/solidus_globalize

 
 

Repository files navigation

Solidus Globalize

Build Status Code Climate

This is the globalization project for Solidus.

NOTE: If you just need to change the language of your store, and will only have data in database in one language, then you don't need this gem, use solidus_i18n, which provides translations for static content (links, headers etc).

This gem adds the model data translation support using the Globalize gem. Read more

Happy translating!


Installation

For Solidus 2.0+, add the following to your Gemfile:

gem 'globalize', github: 'globalize/globalize'
gem 'solidus_i18n', github: 'solidusio-contrib/solidus_i18n'
gem 'solidus_globalize', github: 'solidusio-contrib/solidus_globalize'

For Solidus 1.x, add the following instead:

gem 'globalize', '~> 5.0.0'
gem 'solidus_i18n', github: 'solidusio-contrib/solidus_i18n'
gem 'solidus_globalize', github: 'solidusio-contrib/solidus_globalize'

Run bundle install

You can use the generator to install migrations and append solidus_globalize assets to your app solidus manifest file.

bin/rails g solidus_globalize:install

This will insert these lines into your solidus manifest files:

vendor/assets/javascripts/spree/backend/all.js
//= require spree/backend/solidus_globalize

vendor/assets/stylesheets/spree/frontend/all.css
*= require spree/backend/solidus_globalize

Model Translations

This feature uses the Globalize gem to localize model data. So far the following models are translatable:

Product, Promotion, OptionType, Taxonomy, Taxon, Property and ShippingMethod.

Start your server and you should see a TRANSLATIONS link or a flag icon on each admin section that supports this feature.

There are 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.

SolidusI18n::Config.available_locales = [:en, :es, :'pt-BR'] # displayed on frontend select box
SolidusGlobalize::Config.supported_locales = [:en, :'pt-BR'] # displayed on translation forms

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 solidus_globalize from your Gemfile, add some records and then add solidus_globalize gem back you might get errors like undefined method for nilClass because Globalize will try fetch translations that do not exist.


Contributing

See corresponding guidelines


Copyright (c) 2010-2015 Spree Commerce Inc. and other contributors. released under the New BSD License

About

🌍 Model data globalization for Solidus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 74.8%
  • HTML 19.9%
  • CoffeeScript 4.0%
  • CSS 1.2%
  • JavaScript 0.1%