def verify_available_languages!(options)
      return if options[:skip_metadata]

      # Collect all languages we need
      # We only care about languages from user provided values
      # as the other languages are on iTC already anyway
      v = options[:app].edit_version(platform: options[:platform])
      UI.user_error!("Could not find a version to edit for app '#{options[:app].name}', the app metadata is read-only currently") unless v

      enabled_languages = options[:languages] || []
      LOCALISED_VERSION_VALUES.each do |key|
        current = options[key]
        next unless current && current.kind_of?(Hash)
        current.each do |language, value|
          language = language.to_s
          enabled_languages << language unless enabled_languages.include?(language)
        end
      end

      # Reject "default" language from getting enabled
      # because "default" is not an iTC language
      enabled_languages = enabled_languages.reject do |lang|
        lang == "default"
      end.uniq

      if enabled_languages.count > 0
        v.create_languages(enabled_languages)
        lng_text = "language"
        lng_text += "s" if enabled_languages.count != 1
        Helper.show_loading_indicator("Activating #{lng_text} #{enabled_languages.join(', ')}...")
        v.save!
        Helper.hide_loading_indicator
      end
      true
    end
def verify_available_languages!(options)
      return if options[:skip_metadata]

      # Collect all languages we need
      # We only care about languages from user provided values
      # as the other languages are on iTC already anyway
      v = options[:app].edit_version(platform: options[:platform])
      UI.user_error!("Could not find a version to edit for app '#{options[:app].name}', the app metadata is read-only currently") unless v

      enabled_languages = options[:languages] || []
      LOCALISED_VERSION_VALUES.each do |key|
        current = options[key]
        next unless current && current.kind_of?(Hash)
        current.each do |language, value|
          language = language.to_s
          enabled_languages << language unless enabled_languages.include?(language)
        end
      end

      # Reject "default" language from getting enabled
      # because "default" is not an iTC language
      enabled_languages = enabled_languages.reject do |lang|
        lang == "default"
      end.uniq

      if enabled_languages.count > 0
        v.create_languages(enabled_languages)
        lng_text = "language"
        lng_text += "s" if enabled_languages.count != 1
        Helper.show_loading_indicator("Activating #{lng_text} #{enabled_languages.join(', ')}...")
        v.save!
        Helper.hide_loading_indicator
      end
      true
    end
def verify_available_languages! ( options ) return if options [ :skip_metadata ] # Collect all languages we need # We only care about languages from user provided values # as the other languages are on iTC already anyway v = options [ :app ] . edit_version ( platform : options [ :platform ] ) UI . user_error! ( "Could not find a version to edit for app '#{options[:app].name}', the app metadata is read-only currently" ) unless v enabled_languages = options [ :languages ] || [ ] LOCALISED_VERSION_VALUES . each do | key | current = options [ key ] next unless current && current . kind_of? ( Hash ) current . each do | language , value | language = language . to_s enabled_languages << language unless enabled_languages . include? ( language ) end end # Reject "default" language from getting enabled # because "default" is not an iTC language enabled_languages = enabled_languages . reject do | lang | lang == "default" end . uniq if enabled_languages . count > 0 v . create_languages ( enabled_languages ) lng_text = "language" lng_text += "s" if enabled_languages . count != 1 Helper . show_loading_indicator ( "Activating #{lng_text} #{enabled_languages.join(', ')}..." ) v . save! Helper . hide_loading_indicator end true end
Makes sure all languages we need are actually created
Makes sure all languages we need are actually created