rails-localization 1.2.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 45f814e963b1625936bd65aadc83e4096acdca74
4
- data.tar.gz: dee12c7e218988db2e34be091454a175199002d2
2
+ SHA256:
3
+ metadata.gz: e65d3048e387337c90471103e9ec38a17c626f6c6fc85dd73b2005e2f027ab60
4
+ data.tar.gz: b9c6e5fca7270275eb8a7b2fb7eeb5fa7d6e23d95f59b5b4eef9358c5f7d4b59
5
5
  SHA512:
6
- metadata.gz: 5be965913a0177a17b5f9739cf744a258b7e6e842fdf9fb05de55029ce72eb0855e4688840e00a959e7a8f8fea2f76954062ca67068b9d56fb1d453fd98f5efa
7
- data.tar.gz: 50e6d35007d78709384bc562a52d299157a7cd302d4f74bf1f3a640d3874b3b35ceddbd4a81ea5d43ff6e3bee665eb541d89babd6ae5fe07b15caeac4f7ba7f8
6
+ metadata.gz: 2897451f27d2f64286f03d8df531b87652a5aadb3e290956d037245b00149eaf22e3c4099d60e0f7fd59ad687c704e5bce27969913746a08802bbdb8cbf2121d
7
+ data.tar.gz: 18755b927df0bb3ee81d25a85506864009cca774bfb376346faa51e9b534e6c4e98fc9380133bc64d9d7790e6f0ad689fe92f40f9d5544bccecba6308c295037
@@ -1 +1 @@
1
- ruby-2.0.0
1
+ ruby-2.4.1
data/Gemfile CHANGED
@@ -1,28 +1,26 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rails", ">= 4.0.0"
3
+ gem "rails", ">= 5.0.0"
4
4
  gem "i18n"
5
5
 
6
6
  group :debug do
7
- gem "byebug", platform: :ruby_20
7
+ gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
8
+ #gem "byebug", platform: :ruby_20
8
9
  #gem "debugger", "~> 1.2.2", platform: :ruby_19
9
10
  #gem "ruby-debug", platform: :ruby_18
10
11
  end
11
12
 
12
13
  group :development, :test do
13
- gem "jeweler", "~> 1.8.0"
14
+ gem "jeweler", "~> 2.3"
14
15
  end
15
16
 
16
17
  group :debug, :test do
17
- gem "yard"
18
- gem "redcarpet"
18
+ gem "yard"
19
19
  end
20
20
 
21
21
  group :test do
22
22
  gem 'minitest'
23
23
  gem "test-unit"
24
- gem 'shoulda-context'
25
- gem 'shoulda-matchers'
26
24
 
27
25
  gem "capybara"
28
- end
26
+ end
@@ -1,134 +1,167 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionmailer (4.0.2)
5
- actionpack (= 4.0.2)
6
- mail (~> 2.5.4)
7
- actionpack (4.0.2)
8
- activesupport (= 4.0.2)
9
- builder (~> 3.1.0)
10
- erubis (~> 2.7.0)
11
- rack (~> 1.5.2)
12
- rack-test (~> 0.6.2)
13
- activemodel (4.0.2)
14
- activesupport (= 4.0.2)
15
- builder (~> 3.1.0)
16
- activerecord (4.0.2)
17
- activemodel (= 4.0.2)
18
- activerecord-deprecated_finders (~> 1.0.2)
19
- activesupport (= 4.0.2)
20
- arel (~> 4.0.0)
21
- activerecord-deprecated_finders (1.0.3)
22
- activesupport (4.0.2)
23
- i18n (~> 0.6, >= 0.6.4)
24
- minitest (~> 4.2)
25
- multi_json (~> 1.3)
26
- thread_safe (~> 0.1)
27
- tzinfo (~> 0.3.37)
28
- addressable (2.3.5)
29
- arel (4.0.1)
30
- atomic (1.1.14)
31
- builder (3.1.4)
32
- byebug (2.5.0)
33
- columnize (~> 0.3.6)
34
- debugger-linecache (~> 1.2.0)
35
- capybara (2.2.0)
36
- mime-types (>= 1.16)
37
- nokogiri (>= 1.3.3)
38
- rack (>= 1.0.0)
39
- rack-test (>= 0.5.4)
40
- xpath (~> 2.0)
41
- columnize (0.3.6)
42
- debugger-linecache (1.2.0)
43
- erubis (2.7.0)
44
- faraday (0.8.8)
45
- multipart-post (~> 1.2.0)
46
- git (1.2.6)
47
- github_api (0.10.1)
4
+ actioncable (5.2.0)
5
+ actionpack (= 5.2.0)
6
+ nio4r (~> 2.0)
7
+ websocket-driver (>= 0.6.1)
8
+ actionmailer (5.2.0)
9
+ actionpack (= 5.2.0)
10
+ actionview (= 5.2.0)
11
+ activejob (= 5.2.0)
12
+ mail (~> 2.5, >= 2.5.4)
13
+ rails-dom-testing (~> 2.0)
14
+ actionpack (5.2.0)
15
+ actionview (= 5.2.0)
16
+ activesupport (= 5.2.0)
17
+ rack (~> 2.0)
18
+ rack-test (>= 0.6.3)
19
+ rails-dom-testing (~> 2.0)
20
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
21
+ actionview (5.2.0)
22
+ activesupport (= 5.2.0)
23
+ builder (~> 3.1)
24
+ erubi (~> 1.4)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
27
+ activejob (5.2.0)
28
+ activesupport (= 5.2.0)
29
+ globalid (>= 0.3.6)
30
+ activemodel (5.2.0)
31
+ activesupport (= 5.2.0)
32
+ activerecord (5.2.0)
33
+ activemodel (= 5.2.0)
34
+ activesupport (= 5.2.0)
35
+ arel (>= 9.0)
36
+ activestorage (5.2.0)
37
+ actionpack (= 5.2.0)
38
+ activerecord (= 5.2.0)
39
+ marcel (~> 0.3.1)
40
+ activesupport (5.2.0)
41
+ concurrent-ruby (~> 1.0, >= 1.0.2)
42
+ i18n (>= 0.7, < 2)
43
+ minitest (~> 5.1)
44
+ tzinfo (~> 1.1)
45
+ addressable (2.4.0)
46
+ arel (9.0.0)
47
+ builder (3.2.3)
48
+ byebug (10.0.2)
49
+ capybara (3.3.1)
48
50
  addressable
49
- faraday (~> 0.8.1)
50
- hashie (>= 1.2)
51
- multi_json (~> 1.4)
52
- nokogiri (~> 1.5.2)
53
- oauth2
54
- hashie (2.0.5)
55
- highline (1.6.20)
56
- hike (1.2.3)
57
- httpauth (0.2.0)
58
- i18n (0.6.9)
59
- jeweler (1.8.8)
51
+ mini_mime (>= 0.1.3)
52
+ nokogiri (~> 1.8)
53
+ rack (>= 1.6.0)
54
+ rack-test (>= 0.6.3)
55
+ xpath (~> 3.1)
56
+ concurrent-ruby (1.0.5)
57
+ crass (1.0.4)
58
+ descendants_tracker (0.0.4)
59
+ thread_safe (~> 0.3, >= 0.3.1)
60
+ erubi (1.7.1)
61
+ faraday (0.9.2)
62
+ multipart-post (>= 1.2, < 3)
63
+ git (1.4.0)
64
+ github_api (0.16.0)
65
+ addressable (~> 2.4.0)
66
+ descendants_tracker (~> 0.0.4)
67
+ faraday (~> 0.8, < 0.10)
68
+ hashie (>= 3.4)
69
+ mime-types (>= 1.16, < 3.0)
70
+ oauth2 (~> 1.0)
71
+ globalid (0.4.1)
72
+ activesupport (>= 4.2.0)
73
+ hashie (3.5.7)
74
+ highline (2.0.0)
75
+ i18n (1.0.1)
76
+ concurrent-ruby (~> 1.0)
77
+ jeweler (2.3.9)
60
78
  builder
61
- bundler (~> 1.0)
79
+ bundler
62
80
  git (>= 1.2.5)
63
- github_api (= 0.10.1)
81
+ github_api (~> 0.16.0)
64
82
  highline (>= 1.6.15)
65
- nokogiri (= 1.5.10)
83
+ nokogiri (>= 1.5.10)
84
+ psych
66
85
  rake
67
86
  rdoc
68
- json (1.8.1)
69
- jwt (0.1.8)
70
- multi_json (>= 1.5)
71
- mail (2.5.4)
72
- mime-types (~> 1.16)
73
- treetop (~> 1.4.8)
74
- mime-types (1.25.1)
75
- minitest (4.7.5)
76
- multi_json (1.8.2)
77
- multi_xml (0.5.5)
78
- multipart-post (1.2.0)
79
- nokogiri (1.5.10)
80
- oauth2 (0.9.2)
81
- faraday (~> 0.8)
82
- httpauth (~> 0.2)
83
- jwt (~> 0.1.4)
84
- multi_json (~> 1.0)
87
+ semver2
88
+ jwt (1.5.6)
89
+ loofah (2.2.2)
90
+ crass (~> 1.0.2)
91
+ nokogiri (>= 1.5.9)
92
+ mail (2.7.0)
93
+ mini_mime (>= 0.1.1)
94
+ marcel (0.3.2)
95
+ mimemagic (~> 0.3.2)
96
+ method_source (0.9.0)
97
+ mime-types (2.99.3)
98
+ mimemagic (0.3.2)
99
+ mini_mime (1.0.0)
100
+ mini_portile2 (2.3.0)
101
+ minitest (5.11.3)
102
+ multi_json (1.13.1)
103
+ multi_xml (0.6.0)
104
+ multipart-post (2.0.0)
105
+ nio4r (2.3.1)
106
+ nokogiri (1.8.4)
107
+ mini_portile2 (~> 2.3.0)
108
+ oauth2 (1.4.0)
109
+ faraday (>= 0.8, < 0.13)
110
+ jwt (~> 1.0)
111
+ multi_json (~> 1.3)
85
112
  multi_xml (~> 0.5)
86
- rack (~> 1.2)
87
- polyglot (0.3.3)
88
- rack (1.5.2)
89
- rack-test (0.6.2)
90
- rack (>= 1.0)
91
- rails (4.0.2)
92
- actionmailer (= 4.0.2)
93
- actionpack (= 4.0.2)
94
- activerecord (= 4.0.2)
95
- activesupport (= 4.0.2)
96
- bundler (>= 1.3.0, < 2.0)
97
- railties (= 4.0.2)
98
- sprockets-rails (~> 2.0.0)
99
- railties (4.0.2)
100
- actionpack (= 4.0.2)
101
- activesupport (= 4.0.2)
113
+ rack (>= 1.2, < 3)
114
+ power_assert (1.1.3)
115
+ psych (3.0.2)
116
+ rack (2.0.5)
117
+ rack-test (1.0.0)
118
+ rack (>= 1.0, < 3)
119
+ rails (5.2.0)
120
+ actioncable (= 5.2.0)
121
+ actionmailer (= 5.2.0)
122
+ actionpack (= 5.2.0)
123
+ actionview (= 5.2.0)
124
+ activejob (= 5.2.0)
125
+ activemodel (= 5.2.0)
126
+ activerecord (= 5.2.0)
127
+ activestorage (= 5.2.0)
128
+ activesupport (= 5.2.0)
129
+ bundler (>= 1.3.0)
130
+ railties (= 5.2.0)
131
+ sprockets-rails (>= 2.0.0)
132
+ rails-dom-testing (2.0.3)
133
+ activesupport (>= 4.2.0)
134
+ nokogiri (>= 1.6)
135
+ rails-html-sanitizer (1.0.4)
136
+ loofah (~> 2.2, >= 2.2.2)
137
+ railties (5.2.0)
138
+ actionpack (= 5.2.0)
139
+ activesupport (= 5.2.0)
140
+ method_source
102
141
  rake (>= 0.8.7)
103
142
  thor (>= 0.18.1, < 2.0)
104
- rake (10.1.0)
105
- rdoc (4.0.1)
106
- json (~> 1.4)
107
- redcarpet (3.0.0)
108
- shoulda-context (1.1.6)
109
- shoulda-matchers (2.4.0)
110
- activesupport (>= 3.0.0)
111
- sprockets (2.10.1)
112
- hike (~> 1.2)
113
- multi_json (~> 1.0)
114
- rack (~> 1.0)
115
- tilt (~> 1.1, != 1.3.0)
116
- sprockets-rails (2.0.1)
117
- actionpack (>= 3.0)
118
- activesupport (>= 3.0)
119
- sprockets (~> 2.8)
120
- test-unit (2.5.5)
121
- thor (0.18.1)
122
- thread_safe (0.1.3)
123
- atomic
124
- tilt (1.4.1)
125
- treetop (1.4.15)
126
- polyglot
127
- polyglot (>= 0.3.1)
128
- tzinfo (0.3.38)
129
- xpath (2.0.0)
130
- nokogiri (~> 1.3)
131
- yard (0.8.7.3)
143
+ rake (12.3.1)
144
+ rdoc (6.0.4)
145
+ semver2 (3.4.2)
146
+ sprockets (3.7.2)
147
+ concurrent-ruby (~> 1.0)
148
+ rack (> 1, < 3)
149
+ sprockets-rails (3.2.1)
150
+ actionpack (>= 4.0)
151
+ activesupport (>= 4.0)
152
+ sprockets (>= 3.0.0)
153
+ test-unit (3.2.8)
154
+ power_assert
155
+ thor (0.20.0)
156
+ thread_safe (0.3.6)
157
+ tzinfo (1.2.5)
158
+ thread_safe (~> 0.1)
159
+ websocket-driver (0.7.0)
160
+ websocket-extensions (>= 0.1.0)
161
+ websocket-extensions (0.1.3)
162
+ xpath (3.1.0)
163
+ nokogiri (~> 1.8)
164
+ yard (0.9.15)
132
165
 
133
166
  PLATFORMS
134
167
  ruby
@@ -137,11 +170,11 @@ DEPENDENCIES
137
170
  byebug
138
171
  capybara
139
172
  i18n
140
- jeweler (~> 1.8.0)
173
+ jeweler (~> 2.3)
141
174
  minitest
142
- rails (>= 4.0.0)
143
- redcarpet
144
- shoulda-context
145
- shoulda-matchers
175
+ rails (>= 5.0.0)
146
176
  test-unit
147
177
  yard
178
+
179
+ BUNDLED WITH
180
+ 1.16.2
data/Rakefile CHANGED
@@ -28,7 +28,7 @@ Jeweler::RubygemsDotOrgTasks.new
28
28
  require 'rake/testtask'
29
29
  Rake::TestTask.new(:test) do |test|
30
30
  test.libs << 'lib' << 'test'
31
- test.pattern = 'test/**/*_test.rb'
31
+ test.pattern = 'test/*_test.rb'
32
32
  test.verbose = true
33
33
  end
34
34
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 2.1.0
@@ -5,16 +5,15 @@ require 'rails-localization/engine'
5
5
 
6
6
  if defined?(ActiveSupport)
7
7
  require 'rails-localization/i18n'
8
- require 'rails-localization/url_options'
9
8
 
10
9
  I18n.extend RailsLocalization::I18n
11
10
 
12
11
  ActiveSupport.on_load(:before_configuration) do
13
12
  require 'rails-localization/router'
14
- require 'rails-localization/route_set'
13
+ require 'rails-localization/url_helper'
15
14
 
16
- ActionDispatch::Routing::RouteSet.send :include, RailsLocalization::RouteSet
17
- ActionDispatch::Routing::Mapper.send :include, ActionDispatch::Routing::Mapper::Localization
15
+ ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper.send :prepend, RailsLocalization::UrlHelper
16
+ ActionDispatch::Routing::Mapper.send :prepend, ActionDispatch::Routing::Mapper::Localization
18
17
 
19
18
  ActiveSupport.on_load(:action_controller) do
20
19
  require 'rails-localization/controller'
@@ -23,4 +22,4 @@ if defined?(ActiveSupport)
23
22
  end
24
23
  else
25
24
  warn "ActiveSupport is not defined. Ignoring RailsLocalization loading"
26
- end
25
+ end
@@ -2,7 +2,7 @@ module RailsLocalization
2
2
  module Controller
3
3
  def self.included(base)
4
4
  base.class_eval do
5
- around_filter :process_with_locale
5
+ around_action :process_with_locale
6
6
 
7
7
  protected
8
8
 
@@ -12,11 +12,11 @@ module RailsLocalization
12
12
  ::I18n.locale = params[:locale].blank? ? ::I18n.default_locale : params[:locale].to_s
13
13
  end
14
14
  yield
15
- ensure
15
+ ensure
16
16
  ::I18n.locale = ::I18n.default_locale
17
- end
18
- end
17
+ end
18
+ end
19
19
  end
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -1,9 +1,7 @@
1
1
  module RailsLocalization
2
2
  module I18n
3
- def self.extended(base)
4
- def base.locales
5
- @locales ||= {}
6
- end
3
+ def route_locales
4
+ @route_locales ||= {}
7
5
  end
8
6
  end
9
- end
7
+ end
@@ -1,15 +1,13 @@
1
1
  module ActionDispatch::Routing::Mapper::Localization
2
- def self.included(base)
3
- base.class_eval do
4
- def localized(locales)
5
- if @set == Rails.application.routes
6
- I18n.locales[:main_app] = locales
7
- else
8
- sub_app_name = @scope[:module] || :main_app
9
- I18n.locales[sub_app_name] = locales
10
- end
11
- scope("(:locale)", constraints: {locale: /#{locales.keys.join('|')}/}, defaults: {locale: ""}) { yield }
12
- end
2
+ def localized(*locales)
3
+ symbolized_locales = locales.map(&:to_sym)
4
+ I18n.config.available_locales = symbolized_locales
5
+ if @set == Rails.application.routes
6
+ I18n.route_locales[:main_app] = symbolized_locales
7
+ else
8
+ sub_app_name = @scope[:module] || :main_app
9
+ I18n.route_locales[sub_app_name] = symbolized_locales
13
10
  end
11
+ scope("(:locale)", constraints: {locale: /#{symbolized_locales.join('|')}/}, defaults: {locale: ""}) { yield }
14
12
  end
15
- end
13
+ end
@@ -0,0 +1,38 @@
1
+ module RailsLocalization
2
+ module UrlHelper
3
+ def handle_positional_args(controller_options, inner_options, args, result, path_params)
4
+ options = super
5
+
6
+ if options[:_recall] && options[:_recall].has_key?(:locale) && path_params.include?(:locale)
7
+ if inner_options.has_key?(:locale) && inner_options[:locale].blank?
8
+ options.delete(:locale)
9
+ else
10
+ if inner_options[:locale] && ::I18n.config.available_locales.include?(inner_options[:locale].to_sym)
11
+ if inner_options[:locale].to_s != ::I18n.default_locale.to_s
12
+ options[:locale] = inner_options[:locale]
13
+ else
14
+ options.delete(:locale)
15
+ end
16
+ else
17
+ if ::I18n.locale.to_s != ::I18n.default_locale.to_s
18
+ options[:locale] = ::I18n.locale.to_s
19
+ else
20
+ options.delete(:locale)
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ if options.has_key?(:locale) && !inner_options.has_key?(:locale) && !path_params.include?(:locale)
27
+ options.delete(:locale)
28
+ end
29
+
30
+ if options.has_key?(:_positional_keys) && options[:_positional_keys].includes?(:locale)
31
+ i = options[:_positional_keys].index(:locale)
32
+ options[:_positional_args].insert(i, (options.delete(:locale) || ::I18n.locale.to_s))
33
+ end
34
+
35
+ options
36
+ end
37
+ end
38
+ end
@@ -2,18 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: rails-localization 1.2.0 ruby lib
5
+ # stub: rails-localization 2.1.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = "rails-localization"
9
- s.version = "1.2.0"
8
+ s.name = "rails-localization".freeze
9
+ s.version = "2.1.0"
10
10
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["E-Max"]
14
- s.date = "2014-01-31"
15
- s.description = "This gem allows you to localize your rails application with ease"
16
- s.email = "max@studentify.nl"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["E-Max".freeze]
14
+ s.date = "2018-08-06"
15
+ s.description = "This gem allows you to localize your rails application with ease".freeze
16
+ s.email = "max@studentify.nl".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
19
  "README.rdoc"
@@ -33,9 +33,8 @@ Gem::Specification.new do |s|
33
33
  "lib/rails-localization/controller.rb",
34
34
  "lib/rails-localization/engine.rb",
35
35
  "lib/rails-localization/i18n.rb",
36
- "lib/rails-localization/route_set.rb",
37
36
  "lib/rails-localization/router.rb",
38
- "lib/rails-localization/url_options.rb",
37
+ "lib/rails-localization/url_helper.rb",
39
38
  "lib/rails_localization.rb",
40
39
  "rails-localization.gemspec",
41
40
  "test/i18n_integration_test.rb",
@@ -83,27 +82,27 @@ Gem::Specification.new do |s|
83
82
  "test/test_helper.rb",
84
83
  "test/urls_overwriting_test.rb"
85
84
  ]
86
- s.homepage = "http://github.com/kot-begemot/rails-localization"
87
- s.licenses = ["MIT"]
88
- s.rubygems_version = "2.2.1"
89
- s.summary = "Rails localization Gem"
85
+ s.homepage = "http://github.com/kot-begemot/rails-localization".freeze
86
+ s.licenses = ["MIT".freeze]
87
+ s.rubygems_version = "2.7.7".freeze
88
+ s.summary = "Rails localization Gem".freeze
90
89
 
91
90
  if s.respond_to? :specification_version then
92
91
  s.specification_version = 4
93
92
 
94
93
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
95
- s.add_runtime_dependency(%q<rails>, [">= 4.0.0"])
96
- s.add_runtime_dependency(%q<i18n>, [">= 0"])
97
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.0"])
94
+ s.add_runtime_dependency(%q<rails>.freeze, [">= 5.0.0"])
95
+ s.add_runtime_dependency(%q<i18n>.freeze, [">= 0"])
96
+ s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3"])
98
97
  else
99
- s.add_dependency(%q<rails>, [">= 4.0.0"])
100
- s.add_dependency(%q<i18n>, [">= 0"])
101
- s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
98
+ s.add_dependency(%q<rails>.freeze, [">= 5.0.0"])
99
+ s.add_dependency(%q<i18n>.freeze, [">= 0"])
100
+ s.add_dependency(%q<jeweler>.freeze, ["~> 2.3"])
102
101
  end
103
102
  else
104
- s.add_dependency(%q<rails>, [">= 4.0.0"])
105
- s.add_dependency(%q<i18n>, [">= 0"])
106
- s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
103
+ s.add_dependency(%q<rails>.freeze, [">= 5.0.0"])
104
+ s.add_dependency(%q<i18n>.freeze, [">= 0"])
105
+ s.add_dependency(%q<jeweler>.freeze, ["~> 2.3"])
107
106
  end
108
107
  end
109
108
 
@@ -5,24 +5,24 @@ I18n.extend RailsLocalization::I18n
5
5
 
6
6
  class I18nIntegrationTest < Test::Unit::TestCase
7
7
  setup do
8
- @i18n_locales = I18n.instance_variable_get(:@locales)
9
- I18n.instance_variable_set(:@locales, nil)
8
+ @i18n_locales = I18n.instance_variable_get(:@route_locales)
9
+ I18n.instance_variable_set(:@route_locales, nil)
10
10
  end
11
11
 
12
12
  teardown do
13
- I18n.instance_variable_set(:@locales, @i18n_locales)
13
+ I18n.instance_variable_set(:@route_locales, @i18n_locales)
14
14
  end
15
15
 
16
- test "should Respond to locales" do
17
- assert_respond_to I18n, :locales
16
+ test "should Respond to locales" do
17
+ assert_respond_to I18n, :route_locales
18
18
  end
19
19
 
20
20
  test "should Return locales" do
21
- I18n.instance_variable_set(:@locales, {"en" => "English"})
22
- assert_equal({"en" => "English"}, I18n.locales)
21
+ I18n.instance_variable_set(:@route_locales, ["en"])
22
+ assert_equal(["en"], I18n.route_locales)
23
23
  end
24
24
 
25
25
  test "should Return empty hash if no locales" do
26
- assert_equal({}, I18n.locales)
26
+ assert_equal({}, I18n.route_locales)
27
27
  end
28
- end
28
+ end
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require File.expand_path("test_helper", File.dirname(__FILE__))
3
+ require File.expand_path("support/capybara_helper", File.dirname(__FILE__))
3
4
  require "action_dispatch"
4
5
  require 'active_support/core_ext'
5
6
  require 'rails-localization/router'
@@ -10,12 +11,12 @@ ActionDispatch::Routing::Mapper.send :include, ActionDispatch::Routing::Mapper::
10
11
  class MapperIntegrationTest < Test::Unit::TestCase
11
12
  setup do
12
13
  @route_set = ActionDispatch::Routing::RouteSet.new
13
- @i18n_locales = I18n.instance_variable_get(:@locales)
14
- I18n.instance_variable_set(:@locales, nil)
14
+ @i18n_locales = I18n.instance_variable_get(:@route_locales)
15
+ I18n.instance_variable_set(:@route_locales, nil)
15
16
  end
16
17
 
17
18
  teardown do
18
- I18n.instance_variable_set(:@locales, @i18n_locales)
19
+ I18n.instance_variable_set(:@route_locales, @i18n_locales)
19
20
  end
20
21
 
21
22
  test "should Respond to localized" do
@@ -25,21 +26,20 @@ class MapperIntegrationTest < Test::Unit::TestCase
25
26
 
26
27
  test "should Define locales for I18n" do
27
28
  @route_set.draw do
28
- localized({"en" => "English"}) do; end
29
+ localized("en") do; end
29
30
  end
30
31
 
31
- assert_kind_of(Hash, I18n.locales[:main_app])
32
+ assert_kind_of(Hash, I18n.route_locales[:main_app])
32
33
  end
33
34
 
34
35
  # test "should recognize path" do
35
36
  # @route_set.draw do
36
- # localized({"en" => "English"}) do
37
+ # localized("en") do
37
38
  # resources :posts
38
39
  # root :to => "welcome#index"
39
40
  # end
40
41
  # end
41
42
 
42
- # assert_equal({"en" => "English"}, @route_set.recognize_path("/", {:method => :get}))
43
+ # assert_equal("en", @route_set.recognize_path("/", {:method => :get}))
43
44
  # end
44
45
  end
45
-
@@ -5,6 +5,15 @@ require File.expand_path("support/capybara_helper", File.dirname(__FILE__))
5
5
  class RailsLocalizationTest < ActionDispatch::IntegrationTest
6
6
  include CapybaraHelper
7
7
 
8
+ setup do
9
+ I18n.available_locales = [:en, :ru]
10
+ end
11
+
12
+ teardown do
13
+ ::I18n.locale = ::I18n.default_locale
14
+ I18n.available_locales = []
15
+ end
16
+
8
17
  #context "sub app" do
9
18
  test "should access without locale" do
10
19
  visit "/sub"
@@ -81,7 +90,7 @@ class RailsLocalizationTest < ActionDispatch::IntegrationTest
81
90
  assert_equal 200, page.status_code
82
91
  assert page.has_content? "translation missing: en.main.index"
83
92
  end
84
-
93
+
85
94
  test "root page should access with english locale" do
86
95
  visit "/en"
87
96
  assert_equal 200, page.status_code
@@ -104,27 +113,27 @@ class RailsLocalizationTest < ActionDispatch::IntegrationTest
104
113
  #end
105
114
 
106
115
  #context "welcome page" do
107
- def test_welcome_with_locale_1
116
+ test "page with locale 1 returns context" do
108
117
  visit "/en/welcome"
109
118
  assert_equal 200, page.status_code
110
119
  assert page.has_content? "translation missing: en.main.welcome"
111
120
  end
112
121
 
113
- def test_welcome_with_locale_2
122
+ test "page with locale 2 returns context" do
114
123
  visit "/ru/welcome"
115
124
  assert_equal 200, page.status_code
116
125
  assert page.has_content? "translation missing: ru.main.welcome"
117
126
  end
118
127
  #end
119
-
128
+
120
129
  #context "404" do
121
- def test_wrong_page_without_locale
130
+ test "wrong page without locale" do
122
131
  assert_raise ActionController::RoutingError do
123
132
  visit "/test"
124
133
  end
125
134
  end
126
135
 
127
- def test_wrong_page_with_locale
136
+ test "wrong page with locale" do
128
137
  assert_raise ActionController::RoutingError do
129
138
  visit "en/test"
130
139
  end
@@ -182,4 +191,4 @@ class RailsLocalizationTest < ActionDispatch::IntegrationTest
182
191
  end
183
192
  end
184
193
  #end
185
- end
194
+ end
@@ -1,4 +1,4 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rails", ">= 3.0.0", "< 4.0.0"
4
- gem "rails-localization", path: "../../../rails-localization"
3
+ gem "rails", ">= 5.0.0"
4
+ gem "rails-localization", path: "../../../rails-localization"
@@ -1,93 +1,127 @@
1
1
  PATH
2
- remote: ../../../rails-localization
2
+ remote: ../..
3
3
  specs:
4
- rails-localization (1.0.0)
4
+ rails-localization (1.2.0)
5
5
  i18n
6
- rails (>= 3.0.0, < 4.0.0)
6
+ rails (>= 5.0.0)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionmailer (3.2.15)
12
- actionpack (= 3.2.15)
13
- mail (~> 2.5.4)
14
- actionpack (3.2.15)
15
- activemodel (= 3.2.15)
16
- activesupport (= 3.2.15)
17
- builder (~> 3.0.0)
18
- erubis (~> 2.7.0)
19
- journey (~> 1.0.4)
20
- rack (~> 1.4.5)
21
- rack-cache (~> 1.2)
22
- rack-test (~> 0.6.1)
23
- sprockets (~> 2.2.1)
24
- activemodel (3.2.15)
25
- activesupport (= 3.2.15)
26
- builder (~> 3.0.0)
27
- activerecord (3.2.15)
28
- activemodel (= 3.2.15)
29
- activesupport (= 3.2.15)
30
- arel (~> 3.0.2)
31
- tzinfo (~> 0.3.29)
32
- activeresource (3.2.15)
33
- activemodel (= 3.2.15)
34
- activesupport (= 3.2.15)
35
- activesupport (3.2.15)
36
- i18n (~> 0.6, >= 0.6.4)
37
- multi_json (~> 1.0)
38
- arel (3.0.3)
39
- builder (3.0.4)
40
- erubis (2.7.0)
41
- hike (1.2.3)
42
- i18n (0.6.5)
43
- journey (1.0.4)
44
- json (1.8.1)
45
- mail (2.5.4)
46
- mime-types (~> 1.16)
47
- treetop (~> 1.4.8)
48
- mime-types (1.25.1)
49
- multi_json (1.8.2)
50
- polyglot (0.3.3)
51
- rack (1.4.5)
52
- rack-cache (1.2)
53
- rack (>= 0.4)
54
- rack-ssl (1.3.3)
55
- rack
56
- rack-test (0.6.2)
57
- rack (>= 1.0)
58
- rails (3.2.15)
59
- actionmailer (= 3.2.15)
60
- actionpack (= 3.2.15)
61
- activerecord (= 3.2.15)
62
- activeresource (= 3.2.15)
63
- activesupport (= 3.2.15)
64
- bundler (~> 1.0)
65
- railties (= 3.2.15)
66
- railties (3.2.15)
67
- actionpack (= 3.2.15)
68
- activesupport (= 3.2.15)
69
- rack-ssl (~> 1.3.2)
11
+ actioncable (5.2.0)
12
+ actionpack (= 5.2.0)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailer (5.2.0)
16
+ actionpack (= 5.2.0)
17
+ actionview (= 5.2.0)
18
+ activejob (= 5.2.0)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ rails-dom-testing (~> 2.0)
21
+ actionpack (5.2.0)
22
+ actionview (= 5.2.0)
23
+ activesupport (= 5.2.0)
24
+ rack (~> 2.0)
25
+ rack-test (>= 0.6.3)
26
+ rails-dom-testing (~> 2.0)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ actionview (5.2.0)
29
+ activesupport (= 5.2.0)
30
+ builder (~> 3.1)
31
+ erubi (~> 1.4)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
+ activejob (5.2.0)
35
+ activesupport (= 5.2.0)
36
+ globalid (>= 0.3.6)
37
+ activemodel (5.2.0)
38
+ activesupport (= 5.2.0)
39
+ activerecord (5.2.0)
40
+ activemodel (= 5.2.0)
41
+ activesupport (= 5.2.0)
42
+ arel (>= 9.0)
43
+ activestorage (5.2.0)
44
+ actionpack (= 5.2.0)
45
+ activerecord (= 5.2.0)
46
+ marcel (~> 0.3.1)
47
+ activesupport (5.2.0)
48
+ concurrent-ruby (~> 1.0, >= 1.0.2)
49
+ i18n (>= 0.7, < 2)
50
+ minitest (~> 5.1)
51
+ tzinfo (~> 1.1)
52
+ arel (9.0.0)
53
+ builder (3.2.3)
54
+ concurrent-ruby (1.0.5)
55
+ crass (1.0.4)
56
+ erubi (1.7.1)
57
+ globalid (0.4.1)
58
+ activesupport (>= 4.2.0)
59
+ i18n (1.0.1)
60
+ concurrent-ruby (~> 1.0)
61
+ loofah (2.2.2)
62
+ crass (~> 1.0.2)
63
+ nokogiri (>= 1.5.9)
64
+ mail (2.7.0)
65
+ mini_mime (>= 0.1.1)
66
+ marcel (0.3.2)
67
+ mimemagic (~> 0.3.2)
68
+ method_source (0.9.0)
69
+ mimemagic (0.3.2)
70
+ mini_mime (1.0.0)
71
+ mini_portile2 (2.3.0)
72
+ minitest (5.11.3)
73
+ nio4r (2.3.1)
74
+ nokogiri (1.8.4)
75
+ mini_portile2 (~> 2.3.0)
76
+ rack (2.0.5)
77
+ rack-test (1.0.0)
78
+ rack (>= 1.0, < 3)
79
+ rails (5.2.0)
80
+ actioncable (= 5.2.0)
81
+ actionmailer (= 5.2.0)
82
+ actionpack (= 5.2.0)
83
+ actionview (= 5.2.0)
84
+ activejob (= 5.2.0)
85
+ activemodel (= 5.2.0)
86
+ activerecord (= 5.2.0)
87
+ activestorage (= 5.2.0)
88
+ activesupport (= 5.2.0)
89
+ bundler (>= 1.3.0)
90
+ railties (= 5.2.0)
91
+ sprockets-rails (>= 2.0.0)
92
+ rails-dom-testing (2.0.3)
93
+ activesupport (>= 4.2.0)
94
+ nokogiri (>= 1.6)
95
+ rails-html-sanitizer (1.0.4)
96
+ loofah (~> 2.2, >= 2.2.2)
97
+ railties (5.2.0)
98
+ actionpack (= 5.2.0)
99
+ activesupport (= 5.2.0)
100
+ method_source
70
101
  rake (>= 0.8.7)
71
- rdoc (~> 3.4)
72
- thor (>= 0.14.6, < 2.0)
73
- rake (10.1.0)
74
- rdoc (3.12.2)
75
- json (~> 1.4)
76
- sprockets (2.2.2)
77
- hike (~> 1.2)
78
- multi_json (~> 1.0)
79
- rack (~> 1.0)
80
- tilt (~> 1.1, != 1.3.0)
81
- thor (0.18.1)
82
- tilt (1.4.1)
83
- treetop (1.4.15)
84
- polyglot
85
- polyglot (>= 0.3.1)
86
- tzinfo (0.3.38)
102
+ thor (>= 0.18.1, < 2.0)
103
+ rake (12.3.1)
104
+ sprockets (3.7.2)
105
+ concurrent-ruby (~> 1.0)
106
+ rack (> 1, < 3)
107
+ sprockets-rails (3.2.1)
108
+ actionpack (>= 4.0)
109
+ activesupport (>= 4.0)
110
+ sprockets (>= 3.0.0)
111
+ thor (0.20.0)
112
+ thread_safe (0.3.6)
113
+ tzinfo (1.2.5)
114
+ thread_safe (~> 0.1)
115
+ websocket-driver (0.7.0)
116
+ websocket-extensions (>= 0.1.0)
117
+ websocket-extensions (0.1.3)
87
118
 
88
119
  PLATFORMS
89
120
  ruby
90
121
 
91
122
  DEPENDENCIES
92
- rails (>= 3.0.0, < 4.0.0)
123
+ rails (>= 5.0.0)
93
124
  rails-localization!
125
+
126
+ BUNDLED WITH
127
+ 1.16.2
@@ -1,9 +1,9 @@
1
1
  class MainController < ApplicationController
2
2
  def index
3
- render :text => t('main.index')
3
+ render plain: t('main.index')
4
4
  end
5
5
 
6
6
  def welcome
7
- render :text => t('main.welcome')
7
+ render plain: t('main.welcome')
8
8
  end
9
9
  end
@@ -1,13 +1,13 @@
1
1
  class SubApp::MainController < ApplicationController
2
2
  def print_redirect
3
- render :text => sub_app_engine.print_redirect_path
3
+ render plain: sub_app_engine.print_redirect_path
4
4
  end
5
5
 
6
6
  def index
7
- render :text => t('sub_app.main.index')
7
+ render plain: t('sub_app.main.index')
8
8
  end
9
9
 
10
10
  def welcome
11
- render :text => sub_app_engine.print_redirect_path(:locale => :ru)
11
+ render plain: sub_app_engine.print_redirect_path(locale: :ru)
12
12
  end
13
13
  end
@@ -1,18 +1,17 @@
1
1
  class UsersController < ApplicationController
2
2
  def index
3
- render :text => t('users.index')
3
+ render plain: t('users.index')
4
4
  end
5
5
 
6
6
  def with_locale
7
- render :text => users_path, :layout => false
7
+ render plain: users_path, layout: false
8
8
  end
9
9
 
10
10
  def without_locale
11
- render :text => users_path, :layout => false
11
+ render plain: users_path(:locale => false), layout: false
12
12
  end
13
13
 
14
14
  def with_defined_locale
15
- render :text => users_path(:locale => :ru), :layout => false
15
+ render plain: users_path(:locale => :ru), layout: false
16
16
  end
17
17
  end
18
-
@@ -4,4 +4,4 @@
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
- TestApp::Application.config.secret_token = '2dfa87d4cd5809fc27fae79627ad5203edbc35bad2a5730fe5ef969f0ef736a798480f49e8cfccc9b25f7e12d8ab500d619d4fbe572da497380293fba0c99975'
7
+ TestApp::Application.config.secret_key_base = '2dfa87d4cd5809fc27fae79627ad5203edbc35bad2a5730fe5ef969f0ef736a798480f49e8cfccc9b25f7e12d8ab500d619d4fbe572da497380293fba0c99975'
@@ -7,7 +7,7 @@ SubApp::Engine.routes.draw do
7
7
  end
8
8
 
9
9
  TestApp::Application.routes.draw do
10
- localized({"en" => "English", "ru" => "Russian"}) do
10
+ localized("en", "ru") do
11
11
  mount SubApp::Engine => '/sub', :as => :sub_app_engine
12
12
 
13
13
  get :users, :to => "users#index"
@@ -1,7 +1,7 @@
1
1
  require 'bundler'
2
2
  require 'rack/test'
3
3
  require 'test-unit'
4
- require 'shoulda/context'
4
+ require 'byebug'
5
5
 
6
6
  Bundler.setup(:default, :test)
7
7
 
@@ -3,8 +3,13 @@ require File.expand_path("test_helper", File.dirname(__FILE__))
3
3
  require File.expand_path("support/capybara_helper", File.dirname(__FILE__))
4
4
 
5
5
  class UrlsOverwritingTest < ActionController::TestCase
6
- def teardown
6
+ setup do
7
+ I18n.available_locales = [:en, :ru]
8
+ end
9
+
10
+ teardown do
7
11
  ::I18n.locale = ::I18n.default_locale
12
+ I18n.available_locales = []
8
13
  end
9
14
 
10
15
  test "root" do
@@ -15,4 +20,4 @@ class UrlsOverwritingTest < ActionController::TestCase
15
20
  ::I18n.locale = :ru
16
21
  assert_generates("/ru", :controller => "main", :action => "index", :locale => "ru")
17
22
  end
18
- end
23
+ end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-localization
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - E-Max
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-31 00:00:00.000000000 Z
11
+ date: 2018-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 5.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.0
26
+ version: 5.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jeweler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.8.0
47
+ version: '2.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.8.0
54
+ version: '2.3'
55
55
  description: This gem allows you to localize your rails application with ease
56
56
  email: max@studentify.nl
57
57
  executables: []
@@ -60,10 +60,10 @@ extra_rdoc_files:
60
60
  - LICENSE.txt
61
61
  - README.rdoc
62
62
  files:
63
- - .document
64
- - .ruby-gemset
65
- - .ruby-version
66
- - .travis.yml
63
+ - ".document"
64
+ - ".ruby-gemset"
65
+ - ".ruby-version"
66
+ - ".travis.yml"
67
67
  - Gemfile
68
68
  - Gemfile.lock
69
69
  - LICENSE.txt
@@ -74,9 +74,8 @@ files:
74
74
  - lib/rails-localization/controller.rb
75
75
  - lib/rails-localization/engine.rb
76
76
  - lib/rails-localization/i18n.rb
77
- - lib/rails-localization/route_set.rb
78
77
  - lib/rails-localization/router.rb
79
- - lib/rails-localization/url_options.rb
78
+ - lib/rails-localization/url_helper.rb
80
79
  - lib/rails_localization.rb
81
80
  - rails-localization.gemspec
82
81
  - test/i18n_integration_test.rb
@@ -133,17 +132,17 @@ require_paths:
133
132
  - lib
134
133
  required_ruby_version: !ruby/object:Gem::Requirement
135
134
  requirements:
136
- - - '>='
135
+ - - ">="
137
136
  - !ruby/object:Gem::Version
138
137
  version: '0'
139
138
  required_rubygems_version: !ruby/object:Gem::Requirement
140
139
  requirements:
141
- - - '>='
140
+ - - ">="
142
141
  - !ruby/object:Gem::Version
143
142
  version: '0'
144
143
  requirements: []
145
144
  rubyforge_project:
146
- rubygems_version: 2.2.1
145
+ rubygems_version: 2.7.7
147
146
  signing_key:
148
147
  specification_version: 4
149
148
  summary: Rails localization Gem
@@ -1,12 +0,0 @@
1
- module RailsLocalization
2
- module RouteSet
3
- def self.included(base)
4
- base.class_eval do
5
- def url_for_with_locale(options = {})
6
- url_for_without_locale RailsLocalization::UrlOptions.formatter(options)
7
- end
8
- alias_method_chain :url_for, :locale
9
- end
10
- end
11
- end
12
- end
@@ -1,34 +0,0 @@
1
- module RailsLocalization
2
- module UrlOptions
3
- def self.formatter opts
4
- if opts[:_recall] && opts[:_recall].has_key?(:locale)
5
- opts[:locale] = ::I18n.locale.to_s if opts[:locale].blank?
6
-
7
- if !opts[:script_name].blank?
8
- locale = opts.delete(:locale).to_s
9
- affect_script_name(opts, locale) unless opts[:locale].to_s == ::I18n.default_locale.to_s
10
- else
11
- opts[:locale] = nil if opts[:locale].to_s == ::I18n.default_locale.to_s
12
- end
13
- end
14
-
15
- if opts.has_key?(:_positional_keys) && opts[:_positional_keys].first == :locale
16
- i = opts[:_positional_keys].index(:locale)
17
- opts[:_positional_args].insert i, (opts.delete(:locale) || ::I18n.locale.to_s)
18
- end
19
-
20
- opts
21
- end
22
-
23
- protected
24
-
25
- def self.affect_script_name opts, locale
26
- app_locales = ::I18n.locales[:main_app]
27
- if opts[:script_name] =~ /^\/(#{::I18n.locales[:main_app].keys.join('|')})/
28
- opts[:script_name].gsub!($1, locale)
29
- else
30
- opts[:script_name] = "/#{locale}#{opts[:script_name]}"
31
- end
32
- end
33
- end
34
- end