module RouteTranslator

Constants

Configuration
DEFAULT_CONFIGURATION
TRANSLATABLE_SEGMENT
VERSION

Private Class Methods

check_deprecations() click to toggle source
# File lib/route_translator.rb, line 39
def check_deprecations; end
resolve_host_locale_config_conflicts() click to toggle 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

available_locales() click to toggle 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
config() { |config| ... } click to toggle 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
deprecator() click to toggle source
# File lib/route_translator.rb, line 84
def deprecator
  @deprecator ||= ActiveSupport::Deprecation.new(RouteTranslator::VERSION, 'RouteTranslator')
end
locale_from_params(params) click to toggle 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
locale_param_key() click to toggle source
# File lib/route_translator.rb, line 75
def locale_param_key
  config.locale_param_key
end
reset_config() click to toggle source
# File lib/route_translator.rb, line 59
def reset_config
  @config = nil

  config
end