Module: Perfectline::LocaleRouting::LocaleRouteSet::InstanceMethods
- Defined in:
- lib/locale_routing/locale_route_set.rb
Instance Method Summary collapse
-
#extract_request_environment_with_locale(request) ⇒ Object
override request env extraction to include more info.
- #generate_with_locale(*args) ⇒ Object
-
#recognize_path_with_locale(path, env) ⇒ Object
TODO: support locale in subdomain and top level domain extension.
Instance Method Details
#extract_request_environment_with_locale(request) ⇒ Object
override request env extraction to include more info
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/locale_routing/locale_route_set.rb', line 35 def extract_request_environment_with_locale(request) # merge the original hash with new info extract_request_environment_without_locale(request).merge({ :host => request.host, :port => request.port, :domain => request.domain, :subdomain => request.subdomains.first, :subdomains => request.subdomains }) end |
#generate_with_locale(*args) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/locale_routing/locale_route_set.rb', line 25 def generate_with_locale(*args) # check if locale is set locale = args.first.delete(:locale) returning generate_without_locale(*args) do |result| Perfectline::LocaleRouting::Locale.prepend(result, locale) end end |
#recognize_path_with_locale(path, env) ⇒ Object
TODO: support locale in subdomain and top level domain extension
16 17 18 19 20 21 22 23 |
# File 'lib/locale_routing/locale_route_set.rb', line 16 def recognize_path_with_locale(path, env) # set locale and strip it from the path for recognition path = Perfectline::LocaleRouting::Locale.extract(path, env) # process the route and add the locale parameter to return value returning recognize_path_without_locale(path, env) do |params| params[:locale] = I18n.locale end end |