Class: Danger::DangerTransifex
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerTransifex
- Defined in:
- lib/transifex/plugin.rb
Overview
Plugin to push Transifex translations
Instance Method Summary collapse
-
#configure(project_name, resource_name) ⇒ Object
Configure the Transifex client with your project name and resource.
-
#push_source(type, source) ⇒ Object
Push the source language file to transifex, please note the source is the only allowed resource to use with this method.
Instance Method Details
#configure(project_name, resource_name) ⇒ Object
Configure the Transifex client with your project name and resource. The resource is a single source of translations.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/transifex/plugin.rb', line 15 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_source(type, source) ⇒ Object
Push the source language file to transifex, please note the source is the only allowed resource to use with this method.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/transifex/plugin.rb', line 28 def push_source(type, source) unless @resource.nil? begin ("Translations changed - pushing changes to Transifex") @resource.content.update({:i18n_type => type, :content => source}) ("Translations updated \u{2705}") rescue warn("Updating translations failed \u{274C}") end end end |