Module: RouteTranslator

Extended by:
Host
Defined in:
lib/route_translator.rb,
lib/route_translator/host.rb,
lib/route_translator/route.rb,
lib/route_translator/version.rb,
lib/route_translator/translator.rb,
lib/route_translator/translator/path.rb,
lib/route_translator/locale_sanitizer.rb,
lib/route_translator/translator/path/segment.rb,
lib/route_translator/translator/route_helpers.rb,
lib/route_translator/extensions/action_controller.rb,
lib/route_translator/host_path_consistency_lambdas.rb

Defined Under Namespace

Modules: Controller, Host, HostPathConsistencyLambdas, LocaleSanitizer, TestCase, Translator Classes: Configuration, Route

Constant Summary collapse

TRANSLATABLE_SEGMENT =
/^([-_a-zA-Z0-9]+)(\()?/
VERSION =
'5.5.3'.freeze

Class Method Summary collapse

Methods included from Host

locale_from_host, native_locale?, native_locales

Class Method Details

.available_localesObject



54
55
56
57
58
59
60
61
62
# File 'lib/route_translator.rb', line 54

def available_locales
  locales = config.available_locales

  if locales.any?
    locales.map(&:to_sym)
  else
    I18n.available_locales.dup
  end
end

.config {|@config| ... } ⇒ Object

Yields:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/route_translator.rb', line 34

def config(&block)
  @config                                     ||= Configuration.new
  @config.available_locales                   ||= []
  @config.disable_fallback                    ||= false
  @config.force_locale                        ||= false
  @config.hide_locale                         ||= false
  @config.host_locales                        ||= ActiveSupport::OrderedHash.new
  @config.generate_unlocalized_routes         ||= false
  @config.generate_unnamed_unlocalized_routes ||= false
  @config.locale_param_key                    ||= :locale
  @config.locale_segment_proc                 ||= nil
  @config.verify_host_path_consistency        ||= false

  yield @config if block

  resolve_host_locale_config_conflicts unless @config.host_locales.empty?

  @config
end

.locale_param_keyObject



64
65
66
# File 'lib/route_translator.rb', line 64

def locale_param_key
  config.locale_param_key
end