language_engine 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -3,4 +3,76 @@ language_engine
3
3
 
4
4
  [![Build Status](https://travis-ci.org/dryade/language_engine.svg?branch=master)](https://travis-ci.org/dryade/language_engine)
5
5
 
6
- Rails engine for language
6
+ language_engine is a rails engine for language with :
7
+ * a controller
8
+ * a helper
9
+
10
+ Views and assets are not defined because we think everybody wants to adapt the view in their page.
11
+
12
+ You can access to a demo on [http://appli.chouette.mobi](http://appli.chouette.mobi/chouette2/users/sign_in) with
13
+ * login : demo@chouette.mobi
14
+ * password : chouette
15
+
16
+ Requirements
17
+ ------------
18
+
19
+ This code has been run and tested on Travis with :
20
+ * Ruby 1.9.3
21
+
22
+ Installation
23
+ ------------
24
+
25
+ Add gem to your rails app in Gemfile :
26
+
27
+ ```sh
28
+ gem 'language_engine'
29
+ ```
30
+
31
+ Download gem librairies :
32
+
33
+ ```sh
34
+ bundle install
35
+ ```
36
+
37
+ Usage (with bootstrap plugin)
38
+ ----
39
+
40
+ Can be used inline
41
+ ```html
42
+ <ul class="nav navbar-nav navbar-right">
43
+ <li class="<%= language_class('fr') %>"><%= link_to_language :fr %></li>
44
+ <li class="<%= language_class('en') %>"><%= link_to_language :en %></li>
45
+ </ul>
46
+ ```
47
+
48
+ Or with dropdown :
49
+ ```html
50
+ <ul class="nav navbar-nav navbar-right">
51
+ <li class="dropdown">
52
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">
53
+ <%= image_tag("language_engine/#{selected_language}_flag.png") %><b class='caret'></b>
54
+ </a>
55
+ <ul class="dropdown-menu">
56
+ <li><%= link_to_language :fr %></li>
57
+ <li><%= link_to_language :en %></li>
58
+ </ul>
59
+ </li>
60
+ </ul>
61
+ ```
62
+
63
+ Test
64
+ ----
65
+
66
+ ```sh
67
+ bundle exec rake spec
68
+ ```
69
+
70
+ License
71
+ -------
72
+
73
+ This project is licensed under the MIT license, a copy of which can be found in the [LICENSE](./MIT-LICENSE) file.
74
+
75
+ Support
76
+ -------
77
+
78
+ Users looking for support should file an issue on the GitHub [issue tracking page](../../issues), or file a [pull request](../../pulls) if you have a fix available.
@@ -1,7 +1,11 @@
1
1
  module LanguageEngine::LanguagesHelper
2
2
 
3
3
  def selected_language?( lang)
4
- (session[:language].nil? && lang=="fr") || lang==session[:language].to_s
4
+ (session[:language].nil? && lang==I18n.locale) || lang==session[:language].to_s
5
+ end
6
+
7
+ def selected_language
8
+ session[:language].nil? ? I18n.locale : session[:language].to_s
5
9
  end
6
10
 
7
11
  def language_class( lang)
@@ -10,8 +14,9 @@ module LanguageEngine::LanguagesHelper
10
14
  end
11
15
  end
12
16
 
13
- def link_to_language(language)
14
- link_to image_tag("language_engine/#{language}_flag.png"), language_path(language), :method => :put
17
+ def link_to_language(language, html_options = {})
18
+ html_options.merge( { :method => :put } )
19
+ link_to image_tag("language_engine/#{language}_flag.png"), language_path(language), html_options
15
20
  end
16
21
 
17
22
  end
@@ -1,3 +1,3 @@
1
1
  module LanguageEngine
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -0,0 +1,74 @@
1
+ Connecting to database specified by database.yml
2
+  (0.4ms) begin transaction
3
+ Processing by LanguagesController#show as HTML
4
+ Parameters: {"id"=>"dummy"}
5
+ Redirected to http://test.host/
6
+ Completed 302 Found in 1.0ms (ActiveRecord: 0.0ms)
7
+  (0.1ms) rollback transaction
8
+  (0.1ms) begin transaction
9
+ Processing by LanguagesController#show as HTML
10
+ Parameters: {"id"=>"fr"}
11
+ Redirected to http://test.host/referer
12
+ Completed 302 Found in 0.5ms (ActiveRecord: 0.0ms)
13
+  (0.1ms) rollback transaction
14
+  (0.1ms) begin transaction
15
+ Processing by LanguagesController#show as HTML
16
+ Parameters: {"id"=>"fr"}
17
+ Redirected to http://test.host/
18
+ Completed 302 Found in 0.4ms (ActiveRecord: 0.0ms)
19
+  (0.1ms) rollback transaction
20
+  (0.1ms) begin transaction
21
+ Processing by LanguagesController#update as HTML
22
+ Parameters: {"id"=>"dummy"}
23
+ Redirected to http://test.host/
24
+ Completed 302 Found in 0.9ms (ActiveRecord: 0.0ms)
25
+  (0.1ms) rollback transaction
26
+  (0.1ms) begin transaction
27
+ Processing by LanguagesController#update as HTML
28
+ Parameters: {"id"=>"fr"}
29
+ Redirected to http://test.host/referer
30
+ Completed 302 Found in 0.5ms (ActiveRecord: 0.0ms)
31
+  (0.1ms) rollback transaction
32
+  (0.1ms) begin transaction
33
+ Processing by LanguagesController#update as HTML
34
+ Parameters: {"id"=>"fr"}
35
+ Redirected to http://test.host/
36
+ Completed 302 Found in 0.4ms (ActiveRecord: 0.0ms)
37
+  (0.1ms) rollback transaction
38
+ Connecting to database specified by database.yml
39
+  (0.3ms) begin transaction
40
+ Processing by LanguagesController#show as HTML
41
+ Parameters: {"id"=>"dummy"}
42
+ Redirected to http://test.host/
43
+ Completed 302 Found in 0.6ms (ActiveRecord: 0.0ms)
44
+  (0.1ms) rollback transaction
45
+  (0.0ms) begin transaction
46
+ Processing by LanguagesController#show as HTML
47
+ Parameters: {"id"=>"fr"}
48
+ Redirected to http://test.host/referer
49
+ Completed 302 Found in 0.3ms (ActiveRecord: 0.0ms)
50
+  (0.1ms) rollback transaction
51
+  (0.0ms) begin transaction
52
+ Processing by LanguagesController#show as HTML
53
+ Parameters: {"id"=>"fr"}
54
+ Redirected to http://test.host/
55
+ Completed 302 Found in 0.3ms (ActiveRecord: 0.0ms)
56
+  (0.0ms) rollback transaction
57
+  (0.0ms) begin transaction
58
+ Processing by LanguagesController#update as HTML
59
+ Parameters: {"id"=>"dummy"}
60
+ Redirected to http://test.host/
61
+ Completed 302 Found in 0.5ms (ActiveRecord: 0.0ms)
62
+  (0.1ms) rollback transaction
63
+  (0.0ms) begin transaction
64
+ Processing by LanguagesController#update as HTML
65
+ Parameters: {"id"=>"fr"}
66
+ Redirected to http://test.host/referer
67
+ Completed 302 Found in 0.3ms (ActiveRecord: 0.0ms)
68
+  (0.1ms) rollback transaction
69
+  (0.0ms) begin transaction
70
+ Processing by LanguagesController#update as HTML
71
+ Parameters: {"id"=>"fr"}
72
+ Redirected to http://test.host/
73
+ Completed 302 Found in 0.3ms (ActiveRecord: 0.0ms)
74
+  (0.1ms) rollback transaction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: language_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-06-17 00:00:00.000000000 Z
13
+ date: 2014-07-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -90,6 +90,7 @@ files:
90
90
  - README.md
91
91
  - spec/controllers/languages_controller_spec.rb
92
92
  - spec/spec_helper.rb
93
+ - spec/dummy/log/test.log
93
94
  - spec/dummy/log/development.log
94
95
  - spec/dummy/Rakefile
95
96
  - spec/dummy/config.ru
@@ -135,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
136
  version: '0'
136
137
  segments:
137
138
  - 0
138
- hash: 985121953916174418
139
+ hash: -849374058007294626
139
140
  required_rubygems_version: !ruby/object:Gem::Requirement
140
141
  none: false
141
142
  requirements:
@@ -144,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
145
  version: '0'
145
146
  segments:
146
147
  - 0
147
- hash: 985121953916174418
148
+ hash: -849374058007294626
148
149
  requirements: []
149
150
  rubyforge_project:
150
151
  rubygems_version: 1.8.23
@@ -154,6 +155,7 @@ summary: Rails engine to support language change.
154
155
  test_files:
155
156
  - spec/controllers/languages_controller_spec.rb
156
157
  - spec/spec_helper.rb
158
+ - spec/dummy/log/test.log
157
159
  - spec/dummy/log/development.log
158
160
  - spec/dummy/Rakefile
159
161
  - spec/dummy/config.ru