Sha256: 04aa4bb3c7b52e0254f5b23ba1f02298c6c50ebdcda0a6c72b2c7db9c793b540

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

require 'colorize'

require 'icapps/translations/http'
require 'icapps/translations/import/base'

module Icapps
  module Translations
    module Import
      class Xcode < Base
        class << self
          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
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
icapps-translations-0.2.6 lib/icapps/translations/import/xcode.rb
icapps-translations-0.2.5 lib/icapps/translations/import/xcode.rb
icapps-translations-0.2.4 lib/icapps/translations/import/xcode.rb
icapps-translations-0.2.3 lib/icapps/translations/import/xcode.rb
icapps-translations-0.2.2 lib/icapps/translations/import/xcode.rb