dekiru 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/dekiru.gemspec CHANGED
@@ -15,5 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Dekiru::VERSION
17
17
 
18
+ gem.add_dependency 'http_accept_language', [">= 2.0.0.pre"]
18
19
  gem.add_development_dependency 'rake', [">= 0"]
19
20
  end
data/lib/dekiru.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "dekiru/version"
2
2
  require "dekiru/railtie"
3
3
  require "dekiru/helper"
4
+ require "dekiru/controller_additions"
4
5
 
5
6
  module Dekiru
6
7
  end
@@ -0,0 +1,19 @@
1
+ require "http_accept_language"
2
+
3
+ module Dekiru
4
+ module ControllerAdditions
5
+ def set_locale
6
+ I18n.locale = locale_from_params || locale_from_header
7
+ logger.info "[locale] #{I18n.locale}"
8
+ end
9
+
10
+ def locale_from_params
11
+ (I18n.available_locales & [params[:locale].try(:to_sym)]).first
12
+ end
13
+
14
+ def locale_from_header
15
+ logger.debug "[debug] #{http_accept_language.user_preferred_languages}"
16
+ http_accept_language.compatible_language_from(I18n.available_locales)
17
+ end
18
+ end
19
+ end
@@ -4,6 +4,10 @@ module Dekiru
4
4
  ActiveSupport.on_load(:action_view) do
5
5
  ::ActionView::Base.send :include, Dekiru::Helper
6
6
  end
7
+
8
+ ActiveSupport.on_load(:action_controller) do
9
+ ::ActionController::Base.send :include, Dekiru::ControllerAdditions
10
+ end
7
11
  end
8
12
  end
9
13
  end
@@ -1,3 +1,3 @@
1
1
  module Dekiru
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dekiru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-04 00:00:00.000000000 Z
12
+ date: 2013-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: http_accept_language
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0.pre
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0.pre
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rake
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -41,6 +57,7 @@ files:
41
57
  - Rakefile
42
58
  - dekiru.gemspec
43
59
  - lib/dekiru.rb
60
+ - lib/dekiru/controller_additions.rb
44
61
  - lib/dekiru/helper.rb
45
62
  - lib/dekiru/railtie.rb
46
63
  - lib/dekiru/version.rb
@@ -56,12 +73,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
73
  - - ! '>='
57
74
  - !ruby/object:Gem::Version
58
75
  version: '0'
76
+ segments:
77
+ - 0
78
+ hash: -2706103104152094654
59
79
  required_rubygems_version: !ruby/object:Gem::Requirement
60
80
  none: false
61
81
  requirements:
62
82
  - - ! '>='
63
83
  - !ruby/object:Gem::Version
64
84
  version: '0'
85
+ segments:
86
+ - 0
87
+ hash: -2706103104152094654
65
88
  requirements: []
66
89
  rubyforge_project:
67
90
  rubygems_version: 1.8.23