padrino-contrib 0.1.2 → 0.1.3

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.

Potentially problematic release.


This version of padrino-contrib might be problematic. Click here for more details.

@@ -28,15 +28,32 @@ module Padrino
28
28
 
29
29
  def self.registered(app)
30
30
  app.helpers Padrino::Contrib::AutoLocale::Helpers
31
+ app.extend ClassMethods
31
32
  app.set :locales, [:en]
32
33
  app.before do
33
- if request.path_info =~ /^\/(#{options.locales.join('|')})(?=\/|$)/
34
+ if request.path_info =~ /^\/(#{options.locales.join('|')})\b/
34
35
  I18n.locale = $1.to_sym
35
36
  else
36
- I18n.locale = options.locales.first
37
+ I18n.locale = options.locales[0]
37
38
  end
38
39
  end
39
- end # self.registered
40
+
41
+ def self.padrino_route_added(route, verb, path, args, options, block)
42
+ route.instance_variable_set(:@original_path, "/:lang#{route.original_path}") unless route.original_path =~/:lang/
43
+ end
44
+ end
45
+
46
+ module ClassMethods
47
+ ##
48
+ # We need to add always a lang to all our routes
49
+ #
50
+ def url(*args)
51
+ params = args.extract_options!
52
+ params[:lang] = I18n.locale
53
+ args << params
54
+ super(*args)
55
+ end
56
+ end
40
57
  end # AutoLocale
41
58
  end # Contrib
42
59
  end # Padrino
@@ -1,5 +1,5 @@
1
1
  module Padrino
2
2
  module Contrib
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-contrib
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Davide D'Agostino
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-07-27 00:00:00 +02:00
20
+ date: 2011-07-28 00:00:00 +02:00
21
21
  default_executable:
22
22
  dependencies: []
23
23