Module: RouteTranslator::Host
- Included in:
- RouteTranslator
- Defined in:
- lib/route_translator/host.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.locale_from_host(host) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/route_translator/host.rb', line 24 def locale_from_host(host) locales = RouteTranslator.config.host_locales.each_with_object([]) do |(pattern, locale), result| result << locale.to_sym if host =~ regex_for(pattern) end locales &= I18n.available_locales locales.first&.to_sym end |
Instance Method Details
#native_locale?(locale) ⇒ Boolean
14 15 16 |
# File 'lib/route_translator/host.rb', line 14 def native_locale?(locale) locale.to_s.match(/native_/).present? end |
#native_locales ⇒ Object
18 19 20 |
# File 'lib/route_translator/host.rb', line 18 def native_locales config.host_locales.values.map { |locale| :"native_#{locale}" } end |