I18nHelper
This is a really straightforward I18n locales helper. It can you help to change locale web app on the fly.
add callbacks
If we need to add or skip some callbacks, often skip authentication you can add a initializer on your mother app
Add config/initializers/locales.rb
module LocalesControllerCallbacks
extend ActiveSupport::Concern
included do
skip_before_action :authenticate_user!
end
end
LocalesController.send(:include, LocalesControllerCallbacks)
Features
The locale of app is recorded on current session.
Installation
Add to your top of Gemfile:
gem 'i18n_helper'
Usage
Gem come with two main helpers formatted_locale
and i18n_helper_link
formatted_locale
provide 'Language : English'
title, entirely translated in your current locale
i18n_helper_link
provide links ready to use for call controller for change your web app locales on the fly.
If you need more customize you can call directly i18n_helper
helper, this one provide an Array ready to generate Html select translated in your current locale like that :
[ ['en', 'English'], ['fr', 'French'] ]
Caution
It a really first alpha version of this Helper, if you add any feature please contribute!
User profil locale setting
If you use an authentication system, like Devise
, and your User model
like (Devise Resource
) accessible through the current_user
method helper it automatically set the locale for the who is logged.
Dependencies
- Ruby 2.1
- rails ~> 4.0.2
- i18n-language-translations ~> 0.0.2
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request