route_translator 3.2.2 → 3.2.3

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
2
  SHA1:
3
- metadata.gz: 2978c69c256242672228bd99538e631a12446cef
4
- data.tar.gz: 2fcb536aa8f1ce290696dd3a3e8f44cd84deb8c5
3
+ metadata.gz: ef0e4ac719821950ba3fea3f94d84bec1e09fb5d
4
+ data.tar.gz: afca96b6d293ba9d1a7380f9b325241606b4c6ac
5
5
  SHA512:
6
- metadata.gz: f29d2badba785d4a7dbae525d908b6440a99e77c8ea900ab99eb354898075ae4b131b96a350dde15557f224cf1e9b0a976b33a4880287f0b9480883cc1b39ccf
7
- data.tar.gz: cd7d39f3ab0ca1fdaa108803fcde30e7d87afefdfccb09a097b90f8cbe889fc9ecd3cc2c2b378e8896a3cb07bd2ad8378da4283205b20d43213dd8cbed41515b
6
+ metadata.gz: 2a8dc0d13b2ab963e09537c38df4d29f8e13ff50ea6bf16f0d910500a3fa6a954e39946cb738b3d001ef4f6b3837658d2cc621a530fc03d26d810ac390348760
7
+ data.tar.gz: b2375cb371910ed1563e334b02a67586aaa9b2ce4867478a171ec4f97fc389d4c36449a7eccde3e736021ccce6e1fdd8c3154f55b8e403a8c6725d3414a2323b
@@ -54,7 +54,7 @@ module RouteTranslator
54
54
  def self.translate_path(path, locale)
55
55
  new_path = path.dup
56
56
  final_optional_segments = new_path.slice!(/(\([^\/]+\))$/)
57
- translated_segments = new_path.split("/").map{ |seg| translate_path_segment(seg, locale) }.select{ |seg| !seg.blank? }
57
+ translated_segments = new_path.split(/\/|\./).map{ |seg| translate_path_segment(seg, locale) }.select{ |seg| !seg.blank? }
58
58
 
59
59
  # if not hiding locale then
60
60
  # add locale prefix if it's not the default locale,
@@ -66,7 +66,12 @@ module RouteTranslator
66
66
  end
67
67
  end
68
68
 
69
- "/#{translated_segments.join('/')}#{final_optional_segments}".gsub(/\/\(\//, '(/')
69
+ joined_segments = translated_segments.inject do |memo, segment|
70
+ separator = segment == ':format' ? '.' : '/'
71
+ memo << separator << segment
72
+ end
73
+
74
+ "/#{joined_segments}#{final_optional_segments}".gsub(/\/\(\//, '(/')
70
75
  end
71
76
 
72
77
  def self.translate_name(n, locale)
@@ -1,3 +1,3 @@
1
1
  module RouteTranslator
2
- VERSION = '3.2.2'
2
+ VERSION = '3.2.3'
3
3
  end
data/test/routing_test.rb CHANGED
@@ -285,6 +285,30 @@ class TranslateRoutesTest < ActionController::TestCase
285
285
  end
286
286
  end
287
287
 
288
+ def test_route_with_mandatory_format
289
+ draw_routes do
290
+ localized do
291
+ get 'people.:format', :to => 'people#index'
292
+ end
293
+ end
294
+
295
+ assert_routing '/es/gente.xml', :controller => 'people', :action => 'index', :format => 'xml', :locale => 'es'
296
+ assert_routing '/people.xml', :controller => 'people', :action => 'index', :format => 'xml', :locale => 'en'
297
+ end
298
+
299
+ def test_route_with_optional_format
300
+ draw_routes do
301
+ localized do
302
+ get 'people(.:format)', :to => 'people#index'
303
+ end
304
+ end
305
+
306
+ assert_routing '/es/gente', :controller => 'people', :action => 'index', :locale => 'es'
307
+ assert_routing '/people', :controller => 'people', :action => 'index', :locale => 'en'
308
+ assert_routing '/es/gente.xml', :controller => 'people', :action => 'index', :format => 'xml', :locale => 'es'
309
+ assert_routing '/people.xml', :controller => 'people', :action => 'index', :format => 'xml', :locale => 'en'
310
+ end
311
+
288
312
  def test_i18n_based_translations_setting_locales
289
313
  config_default_locale_settings 'en'
290
314
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: route_translator
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raul Murciano
@@ -9,48 +9,48 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-18 00:00:00.000000000 Z
12
+ date: 2014-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: 4.7.0
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: 4.7.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: pry
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: pry-nav
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  description: Translates the Rails routes of your application into the languages defined
@@ -91,17 +91,17 @@ require_paths:
91
91
  - lib
92
92
  required_ruby_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - ">="
99
+ - - '>='
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.2.0
104
+ rubygems_version: 2.0.14
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Translate your Rails routes in a simple manner