0.0
No commit activity in last 3 years
No release in over 3 years
Rails engine to support language change.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.1.0

Runtime

~> 4.1.1
 Project Readme

language_engine

Build Status

language_engine is a rails engine for language with :

  • a controller
  • a helper

Views and assets are not defined because we think everybody wants to adapt the view in their page.

You can access to a demo on http://appli.chouette.mobi with

Requirements

This code has been run and tested on Travis with :

  • Ruby 1.9.3

Installation

Add gem to your rails app in Gemfile :

gem 'language_engine'

Download gem librairies :

bundle install

Usage (with bootstrap plugin)

First you must set local in your application controller for example :

class ApplicationController < ActionController::Base
  protect_from_forgery
  helper LanguageEngine::Engine.helpers
  before_filter :set_locale
 
  def set_locale
    I18n.locale = session[:language] || I18n.default_locale
  end
  
end  

And then you can use it inline :

 <ul class="nav navbar-nav navbar-right">
   <li class="<%= language_class('fr') %>"><%= link_to_language :fr %></li>
   <li class="<%= language_class('en') %>"><%= link_to_language :en %></li>
 </ul>

Or with dropdown :

<ul class="nav navbar-nav navbar-right">
  <li class="dropdown languages">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
      <%= image_tag("language_engine/#{selected_language}_flag.png", { :'data-locale' => "#{selected_language}" } ) %><b class='caret'></b>
    </a>
    <ul class="dropdown-menu">
      <li><%= link_to_language :fr, { :class => language_class( :fr ) } %></li>
      <li><%= link_to_language :en, { :class => language_class( :en  ) } %></li>
    </ul>
  </li>
</ul>  

Test

bundle exec rake spec

License

This project is licensed under the MIT license, a copy of which can be found in the LICENSE file.

Support

Users looking for support should file an issue on the GitHub issue tracking page, or file a pull request if you have a fix available.