Module: I18n::Backend::Chain::Implementation
- Includes:
- Base
- Included in:
- I18n::Backend::Chain
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb
Constant Summary
Transliterator::DEFAULT_REPLACEMENT_CHAR
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Base
#load_translations
get, #transliterate
Instance Attribute Details
Returns the value of attribute backends.
23
24
25
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb', line 23
def backends
@backends
end
|
Instance Method Details
#available_locales ⇒ Object
50
51
52
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb', line 50
def available_locales
backends.map { |backend| backend.available_locales }.flatten.uniq
end
|
#eager_load! ⇒ Object
42
43
44
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb', line 42
def eager_load!
backends.each { |backend| backend.eager_load! }
end
|
#exists?(locale, key, options = EMPTY_HASH) ⇒ Boolean
74
75
76
77
78
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb', line 74
def exists?(locale, key, options = EMPTY_HASH)
backends.any? do |backend|
backend.exists?(locale, key, options)
end
end
|
#initialize(*backends) ⇒ Object
25
26
27
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb', line 25
def initialize(*backends)
self.backends = backends
end
|
#initialized? ⇒ Boolean
29
30
31
32
33
34
35
36
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb', line 29
def initialized?
backends.all? do |backend|
backend.instance_eval do
return false unless initialized?
end
end
true
end
|
#localize(locale, object, format = :default, options = EMPTY_HASH) ⇒ Object
80
81
82
83
84
85
86
87
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb', line 80
def localize(locale, object, format = :default, options = EMPTY_HASH)
backends.each do |backend|
catch(:exception) do
result = backend.localize(locale, object, format, options) and return result
end
end
throw(:exception, I18n::MissingTranslation.new(locale, format, options))
end
|
38
39
40
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb', line 38
def reload!
backends.each { |backend| backend.reload! }
end
|
#store_translations(locale, data, options = EMPTY_HASH) ⇒ Object
46
47
48
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb', line 46
def store_translations(locale, data, options = EMPTY_HASH)
backends.first.store_translations(locale, data, options)
end
|
#translate(locale, key, default_options = EMPTY_HASH) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/chain.rb', line 54
def translate(locale, key, default_options = EMPTY_HASH)
namespace = nil
options = Utils.except(default_options, :default)
backends.each do |backend|
catch(:exception) do
options = default_options if backend == backends.last
translation = backend.translate(locale, key, options)
if namespace_lookup?(translation, options)
namespace = _deep_merge(translation, namespace || {})
elsif !translation.nil? || (options.key?(:default) && options[:default].nil?)
return translation
end
end
end
return namespace if namespace
throw(:exception, I18n::MissingTranslation.new(locale, key, options))
end
|