Sha256: a4f4a4290473a2970e5eabc0659ea96c9c981197548db9f80c577d53f8ef97c8

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

module Danger
  # Plugin to push Transifex translations
  #
  # @example Pushes your source language translations
  #
  #          transifex.push_source(path/to/your.strings)
  #
  # @see  Emil Bogren/danger-transifex
  # @tags translations, transifex
  #
  class DangerTransifex < Plugin

    # Configure the Transifex client with your project name and resource.
    # The resource is a single source of translations.
    def configure(project_name, resource_name)
      require 'transifex'
      Transifex.configure do |c|
        c.client_login = ENV['TRANSIFEX_API']
        c.client_secret = ENV['TRANSIFEX_API_TOKEN']
      end

      @project = Transifex::Project.new(project_name)
      @resource = @project.resource(resource_name)
    end

    # Push the source language file to transifex, please note the source
    # is the only allowed resource to use with this method.
    def push_source(type, source)
      unless @resource.nil?
        begin
          message("Translations changed - pushing changes to Transifex")
          @resource.content.update({:i18n_type => type, :content => source})
          message("Translations updated \u{2705}")
        rescue
          warn("Updating translations failed \u{274C}")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-transifex-0.0.1 lib/transifex/plugin.rb