module RouteTranslator
Constants
- Configuration
- DEFAULT_CONFIGURATION
- TRANSLATABLE_SEGMENT
- VERSION
Private Class Methods
Source
# File lib/route_translator.rb, line 32 def resolve_host_locale_config_conflicts @config.force_locale = false @config.generate_unlocalized_routes = false @config.generate_unnamed_unlocalized_routes = false @config.hide_locale = true end
Public Instance Methods
Source
# File lib/route_translator.rb, line 65 def available_locales locales = config.available_locales if locales.empty? I18n.available_locales.dup else locales.map(&:to_sym) end end
Source
# File lib/route_translator.rb, line 44 def config @config ||= Configuration.new DEFAULT_CONFIGURATION.each do |option, value| @config[option] ||= value end yield @config if block_given? resolve_host_locale_config_conflicts if @config.host_locales.present? check_deprecations @config end
Source
# File lib/route_translator.rb, line 88 def deprecator @deprecator ||= ActiveSupport::Deprecation.new(RouteTranslator::VERSION, 'RouteTranslator') end
Source
# File lib/route_translator.rb, line 79 def locale_from_params(params) locale = params[config.locale_param_key]&.to_sym locale if I18n.available_locales.include?(locale) end
Source
# File lib/route_translator.rb, line 84 def locale_from_request(request) locale_from_params(request.params) || Host.locale_from_host(request.host) end
Source
# File lib/route_translator.rb, line 75 def locale_param_key config.locale_param_key end
Source
# File lib/route_translator.rb, line 59 def reset_config @config = nil config end