- Add gem ‘translation_panel’ in your Gemfile
- Run redis-server
- Set up redis connection settings and register RedisTranslator::Backend as
i18n backend in initializers:
I18n.backend = TranslationPanel::RedisBackend.new(Redis.new)
# or in chain with another backend
- Create predicate method translation_panel? in ApplicationController,
define in it, when panel can be shown and when translates can be saved. By
default always.
def translation_panel?
params[:translator].present?
end
- Wrap your translations in span with ‘data-tranlation-key’ attribute, if you
want to highlight your translation, and edit-on-click. Eg (in haml format):
%span{:data => {'tranlation-key' => "some.key"}}
= t("some.key")
TranslationPanel uses assets, scss, coffeescript, as all its work in Rails 3.1.
If you want to use panel with Rails 3.0, you need to use sprockets gem. Also you
need at least i18n-0.6.0 for proper work with i18n keys
Redis backend support pluralization.
1. You need to use Simple backend with included I18n::Pluralization in chain:
I18n::Backend::Simple.include I18n::Backend::Pluralization
redis_backend = TranslationPanel::RedisBackend.new(Redis.new)
I18n.backend = I18n::Backend::Chain.new(redis_backend, I18n::Backend::Simple.new)
2. You need to add in config/locales/*.yml files rules for pluralization:
i18n:
plural:
keys:
- one
- other