Module: ActionDispatch::Routing::Mapper::Localization

Defined in:
lib/rails-localization/router.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/rails-localization/router.rb', line 2

def self.included(base)
  base.class_eval do
    def localized(locales)
      if @set == Rails.application.routes
        I18n.locales[:main_app] = locales
      else
        sub_app_name = @scope[:module] || :main_app
        I18n.locales[sub_app_name] = locales
      end
      scope("(:locale)", constraints: {locale: /#{locales.keys.join('|')}/}, defaults: {locale: ""}) { yield }
    end
  end
end