Sha256: 466d477a534fd6085b27c0a7f1a22ca5979f70137afde58d5e345cb842549a2b

Contents?: true

Size: 939 Bytes

Versions: 3

Compression:

Stored size: 939 Bytes

Contents

require_relative './crowd_translate_client'

module I18n
  module Migrations
    module Backends
      class CrowdTranslateBackend
        attr_reader :client

        def initialize
          @client = CrowdTranslateClient.new
        end

        def pull(locale)
          pull_from_crowd_translate(locale)
          locale.migrate!
        end

        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

        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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
i18n-migrations-1.2.3 lib/i18n/migrations/backends/crowd_translate_backend.rb
i18n-migrations-1.2.2 lib/i18n/migrations/backends/crowd_translate_backend.rb
i18n-migrations-1.2.0 lib/i18n/migrations/backends/crowd_translate_backend.rb