Class: I18n::OneSky::ActiveRecordClient
- Inherits:
-
ClientBase
- Object
- ClientBase
- I18n::OneSky::ActiveRecordClient
- Defined in:
- lib/i18n/one_sky/active_record_client.rb
Overview
A class to deal with the OneSky apis it encapsulates the logic of I18n::Backend::ActiveRecord
Constant Summary
Constants inherited from ClientBase
Instance Attribute Summary
Attributes inherited from ClientBase
Instance Method Summary collapse
-
#all_phrases ⇒ Object
Grab all the keys from the active record store.
- #download ⇒ Object
- #upload ⇒ Object
Methods inherited from ClientBase
config_exists?, from_config, from_env, #initialize, load_config, #platform_base_locale, #platform_details, #platform_locale_codes, #platform_locales, #verify!
Constructor Details
This class inherits a constructor from I18n::OneSky::ClientBase
Instance Method Details
#all_phrases ⇒ Object
Grab all the keys from the active record store.
38 39 40 41 42 43 44 |
# File 'lib/i18n/one_sky/active_record_client.rb', line 38 def all_phrases phrases = Hash.new translation_scope(I18n.default_locale).find_each() do |translation| phrases[translation.key] = translation.value end phrases end |
#download ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/i18n/one_sky/active_record_client.rb', line 10 def download puts "Downloading translations for I18n Active Record Backend:" platform_locales.each do |locale| locale_code = locale["locale"] local_name = locale["name"]["local"] english_name = locale["name"]["eng"] i18n_locale_code = locale_os_to_i18n(locale_code) if locale_code == platform_base_locale # we skip the base next else yaml = platform.translation.download_yaml(locale_code) YAML.load(yaml).each do |code, translations| active_record_backend.store_translations(i18n_locale_code, translations) puts " locale: #{i18n_locale_code}, count: #{translation_scope(i18n_locale_code).count}" end end end end |
#upload ⇒ Object
33 34 35 |
# File 'lib/i18n/one_sky/active_record_client.rb', line 33 def upload upload_phrases(all_phrases) end |