Module: Globalize
- Defined in:
- lib/globalize/active_record/attributes.rb,
lib/globalize.rb,
lib/globalize/utils.rb,
lib/globalize/engine.rb,
lib/globalize/versioning.rb,
lib/globalize/active_record.rb,
lib/globalize/active_record/adapter.rb,
lib/globalize/versioning/paper_trail.rb,
lib/globalize/active_record/accessors.rb,
lib/globalize/active_record/act_macro.rb,
lib/globalize/active_record/migration.rb,
lib/globalize/active_record/exceptions.rb,
lib/globalize/active_record/translation.rb,
lib/globalize/active_record/class_methods.rb,
lib/globalize/active_record/instance_methods.rb
Overview
Helper class for storing values per locale. Used by Globalize::Adapter to stash and cache attribute values.
Defined Under Namespace
Modules: ActiveRecord, Versioning
Classes: Engine, Utils
Class Method Summary
collapse
Class Method Details
.available_locales ⇒ Object
43
44
45
|
# File 'lib/globalize.rb', line 43
def available_locales
@@available_locales || I18n.backend.available_locales
end
|
.fallbacks(locale = self.locale) ⇒ Object
39
40
41
|
# File 'lib/globalize.rb', line 39
def fallbacks(locale = self.locale)
fallbacks? ? I18n.fallbacks[locale] : [locale.to_sym]
end
|
.fallbacks? ⇒ Boolean
35
36
37
|
# File 'lib/globalize.rb', line 35
def fallbacks?
I18n.respond_to?(:fallbacks)
end
|
.locale ⇒ Object
13
14
15
|
# File 'lib/globalize.rb', line 13
def locale
read_locale || I18n.locale
end
|
.locale=(locale) ⇒ Object
17
18
19
|
# File 'lib/globalize.rb', line 17
def locale=(locale)
set_locale(locale)
end
|
.with_locale(locale, &block) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/globalize.rb', line 21
def with_locale(locale, &block)
previous_locale = read_locale
set_locale(locale)
result = yield(locale)
set_locale(previous_locale)
result
end
|
.with_locales(*locales, &block) ⇒ Object
29
30
31
32
33
|
# File 'lib/globalize.rb', line 29
def with_locales(*locales, &block)
locales.flatten.map do |locale|
with_locale(locale, &block)
end
end
|