Class: Icapps::Translations::Import::Xcode

Inherits:
Base
  • Object
show all
Defined in:
lib/icapps/translations/import/xcode.rb

Class Method Summary collapse

Methods inherited from Base

config, fetch_languages, import, options, write_to_file

Class Method Details

.fetch_language_file(language) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/icapps/translations/import/xcode.rb', line 11

def fetch_language_file(language)
  short_name = language['short_name']
  puts "[VERBOSE] Fetching #{short_name} translations.".colorize(:white) if options[:verbose]
  # Ignore the .strings files in the Build folder.
  string_files = Dir.glob("**/#{short_name}.lproj/#{config.filename}").reject{ |f| f[%r{^Build/}] }
  if string_files.count == 0
    puts "[WARNING] No 'Localizable.string' file found for the #{short_name} language.".colorize(:yellow)
  elsif string_files.count > 1
    puts "[WARNING] Multiple 'Localizable.string' files found for the #{short_name} language.".colorize(:yellow)
  else
    strings = ::Icapps::Translations::Http.authenticated_response("translations/#{language['id']}.strings")
    write_to_file strings, string_files, language
  end
end