rails-localization 0.2.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use --create 1.9.2@rails-localization
@@ -1,8 +0,0 @@
1
- require 'localization-middleware'
2
-
3
- module Rails
4
- module Localization
5
- class UnknownLocaleError < Exception; end
6
- class Middleware < ::Localization::Middleware; end
7
- end
8
- end
@@ -1,61 +0,0 @@
1
- require 'active_support'
2
-
3
- module Rails
4
- module Localization
5
- module RoutesSetExt
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- def url_for_with_locale(options = {})
10
- finalize!
11
- options = (options || {}).reverse_merge!(default_url_options)
12
-
13
- handle_positional_args(options)
14
-
15
- user, password = extract_authentication(options)
16
- path_segments = options.delete(:_path_segments)
17
- script_name = options.delete(:script_name)
18
-
19
- path = options[:host].blank? ? '' : get_locale_segment(options).to_s
20
- path << (script_name.blank? ? _generate_prefix(options) : script_name.chomp('/')).to_s
21
-
22
- path_options = options.except(*self.class::RESERVED_OPTIONS)
23
- path_options = yield(path_options) if block_given?
24
-
25
- path_addition, params = generate(path_options, path_segments || {})
26
- path << path_addition
27
- params.merge!(options[:params] || {})
28
-
29
- ActionDispatch::Http::URL.url_for(options.merge!({
30
- :path => path,
31
- :params => params,
32
- :user => user,
33
- :password => password
34
- }))
35
- end
36
- alias_method :url_for, :url_for_with_locale
37
-
38
- protected
39
-
40
- def get_locale_segment parameters
41
- parameters ||= {}
42
- locale = parameters.delete(:locale)
43
- return if locale == false
44
- locale ||= ::I18n.locale
45
-
46
- if locale.to_sym != ::I18n.default_locale
47
- raise Rails::Localization::UnknownLocaleError.new("Not supported locale: #{locale}. If this locale should be \
48
- supported, add it to Middelware (#{Rails.root.join('config','application.rb')})") unless Rails::Localization::Middleware.languages.include?(locale.to_s)
49
-
50
- "/#{locale}"
51
- end
52
- end
53
-
54
- end
55
- end
56
- end
57
- end
58
-
59
- ActiveSupport.on_load(:before_initialize) do
60
- ActionDispatch::Routing::RouteSet.send :include, Rails::Localization::RoutesSetExt
61
- end