Class: AppLocale::Pull
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- AppLocale::Pull
- Defined in:
- lib/applocale/pull.rb
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
Methods inherited from BaseCommand
Constructor Details
This class inherits a constructor from AppLocale::BaseCommand
Instance Method Details
#call(languages) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/applocale/pull.rb', line 3 def call(languages) # The user did not pass in specifc languages to ask AppLocale about. # Let's fetch the languages for the project and then loop over them. if languages.empty? puts "[AppLocale] Fetching list of languages..." response = client.project_information if response.dig("success") languages = response.dig("languages") puts "[AppLocale] ↳ Received #{languages} from AppLocale..." if [:verbose] else puts "[AppLocale] #{response.dig("message")}" exit 1 end end if languages.any? languages.each do |language_code| puts "[AppLocale] Fetching translations for #{language_code}..." response = client.export(language_code) if response.dig("success") puts "[AppLocale] ↳ Received #{response} from AppLocale" if [:verbose] AppLocale::FileWriter.new(config, ).call(response) else puts "[AppLocale] #{response.dig("message")}" exit 1 end end else puts "[AppLocale] Sorry, no languages were found for the project." exit 1 end end |