Module: RouteTranslator::Host
- Included in:
- RouteTranslator
- Defined in:
- lib/route_translator/host.rb
Class Method Summary collapse
Class Method Details
.lambdas_for_locale(locale) ⇒ Object
28 29 30 |
# File 'lib/route_translator/host.rb', line 28 def lambdas_for_locale(locale) lambdas[locale] ||= ->(req) { locale == RouteTranslator::Host.locale_from_host(req.host) } end |
.locale_from_host(host) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/route_translator/host.rb', line 20 def locale_from_host(host) locales = RouteTranslator.config.host_locales.each_with_object([]) do |(pattern, locale), result| result << locale.to_sym if host&.match?(regex_for(pattern)) end locales &= I18n.available_locales locales.first&.to_sym end |