Class: I18n::Backend::SimpleStorage
- Defined in:
- lib/i18n/backend/simple_storage.rb
Constant Summary collapse
- @@sort_keys =
true
Class Method Summary collapse
Instance Method Summary collapse
- #copy_translations(from, to) ⇒ Object
- #interpolate(locale, original, values = {}) ⇒ Object
- #remove_translation(key) ⇒ Object
- #save_translations(filenames = I18n.load_path.flatten) ⇒ Object
- #store_translations(locale, data) ⇒ Object
Class Method Details
.sort_keys ⇒ Object
14 15 16 |
# File 'lib/i18n/backend/simple_storage.rb', line 14 def sort_keys @@sort_keys end |
.sort_keys=(sort_keys) ⇒ Object
18 19 20 |
# File 'lib/i18n/backend/simple_storage.rb', line 18 def sort_keys=(sort_keys) @@sort_keys = sort_keys end |
Instance Method Details
#copy_translations(from, to) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/i18n/backend/simple_storage.rb', line 33 def copy_translations(from, to) init_translations unless initialized? I18n.available_locales.each do |locale| store_translations(locale, to => I18n.t(from, :raise => true)) end end |
#interpolate(locale, original, values = {}) ⇒ Object
23 24 25 26 |
# File 'lib/i18n/backend/simple_storage.rb', line 23 def interpolate(locale, original, values = {}) return original unless original.is_a?(String) super.tap { |string| set_translation_properties(string, original.properties) } end |
#remove_translation(key) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/i18n/backend/simple_storage.rb', line 40 def remove_translation(key) init_translations unless initialized? key = I18n.send(:normalize_translation_keys, nil, key, nil) keys = available_locales.map { |locale| [locale] + key } translations.delete_nested_if { |k, v| keys.include?(k) } end |