Class: I18n::Migrations::Backends::CrowdTranslateBackend
- Inherits:
-
Object
- Object
- I18n::Migrations::Backends::CrowdTranslateBackend
- Defined in:
- lib/i18n/migrations/backends/crowd_translate_backend.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize ⇒ CrowdTranslateBackend
constructor
A new instance of CrowdTranslateBackend.
- #pull(locale) ⇒ Object
- #pull_from_crowd_translate(locale) ⇒ Object
- #push(locale, force = false) ⇒ Object
Constructor Details
#initialize ⇒ CrowdTranslateBackend
Returns a new instance of CrowdTranslateBackend.
9 10 11 |
# File 'lib/i18n/migrations/backends/crowd_translate_backend.rb', line 9 def initialize @client = CrowdTranslateClient.new end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/i18n/migrations/backends/crowd_translate_backend.rb', line 7 def client @client end |
Instance Method Details
#pull(locale) ⇒ Object
13 14 15 16 |
# File 'lib/i18n/migrations/backends/crowd_translate_backend.rb', line 13 def pull(locale) pull_from_crowd_translate(locale) locale.migrate! end |
#pull_from_crowd_translate(locale) ⇒ Object
29 30 31 32 33 |
# File 'lib/i18n/migrations/backends/crowd_translate_backend.rb', line 29 def pull_from_crowd_translate(locale) data = @client.get_locale_file(locale.name) locale.write_raw_data("#{locale.name}.yml", data) locale.write_remote_version(YAML::load(data)[locale.name]) end |
#push(locale, force = false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/i18n/migrations/backends/crowd_translate_backend.rb', line 18 def push(locale, force = false) raise "CrowdTranslate does not support -f flag yet" if force # do this just once unless @migrations_synced @client.sync_migrations(locale.migrations) @migrations_synced = true end pull(locale) end |