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]+)(\()?/.freeze
- DEFAULT_CONFIGURATION =
{
available_locales: [],
disable_fallback: false,
force_locale: false,
generate_unlocalized_routes: false,
generate_unnamed_unlocalized_routes: false,
hide_locale: false,
host_locales: {},
locale_param_key: :locale,
locale_segment_proc: false,
verify_host_path_consistency: false
}.freeze
- VERSION =
'7.0.0'
Class Method Summary
collapse
Methods included from Host
locale_from_host, native_locale?, native_locales
Class Method Details
.available_locales ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/route_translator.rb', line 58
def available_locales
locales = config.available_locales
if locales.any?
locales.map(&:to_sym)
else
I18n.available_locales.dup
end
end
|
.config {|@config| ... } ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/route_translator.rb', line 44
def config(&block)
@config ||= Configuration.new
DEFAULT_CONFIGURATION.each do |option, value|
@config[option] ||= value
end
yield @config if block
resolve_host_locale_config_conflicts unless @config.host_locales.empty?
@config
end
|
.locale_from_params(params) ⇒ Object
72
73
74
75
|
# File 'lib/route_translator.rb', line 72
def locale_from_params(params)
locale = params[config.locale_param_key]&.to_sym
locale if I18n.available_locales.include?(locale)
end
|
.locale_param_key ⇒ Object
68
69
70
|
# File 'lib/route_translator.rb', line 68
def locale_param_key
config.locale_param_key
end
|