Module: Pindo::AppstoreMetadataConnectApiHelper

Included in:
Command::Deploy::Getitcinfo, Command::Deploy::Itcinfo
Defined in:
lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb

Instance Method Summary collapse

Instance Method Details

#all_languagesObject



9
10
11
12
13
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 9

def all_languages
	 lang_array =  %w[ar-SA ca cs da de-DE el en-AU en-CA en-GB en-US es-ES es-MX fi fr-CA fr-FR he hi hr hu id it ja ko ms nl-NL no pl pt-BR pt-PT ro ru sk sv th tr uk vi zh-Hans zh-Hant]

	 return lang_array
end

#camel_case_lower(string: nil) ⇒ Object



60
61
62
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 60

def camel_case_lower(string: nil)
  string.split('_').inject([]) { |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
end

#change_img_sort(lang_screenshots_path: nil) ⇒ Object



959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 959

def change_img_sort(lang_screenshots_path:nil)

    new_sort_index = [0,1, 2, 8, 9, 7, 3, 4, 5, 6]

    bacK_lang_screenshots_path = lang_screenshots_path + "_bak"
    FileUtils.rm_rf(bacK_lang_screenshots_path) if Dir.exist?(bacK_lang_screenshots_path)
    FileUtils.mv(lang_screenshots_path, bacK_lang_screenshots_path, force:true)

    all_lang_file_obj = {}
    Dir.glob(File.join(bacK_lang_screenshots_path, "*")).each do |bak_image_full_name|
        image_dir_basename = File.basename(bak_image_full_name)
        extname = File.extname(bak_image_full_name).delete('.')
        # puts "bak_image_full_name:#{bak_image_full_name}"
        if File.file?(bak_image_full_name) && valid_file_extensions.include?(extname)
            # puts "bak_image_full_name:#{bak_image_full_name}"
            extension = File.extname(bak_image_full_name)
            base_name = File.basename(bak_image_full_name, extension)
            deveice_name = base_name.slice(0...-3)
            # puts "deveice_name:#{deveice_name}"
            all_lang_file_obj[deveice_name] = all_lang_file_obj[deveice_name] || []
            all_lang_file_obj[deveice_name].push(bak_image_full_name)

        end
    end

    # puts JSON.pretty_generate(all_lang_file_obj)

    FileUtils.mkdir_p(lang_screenshots_path)
    all_lang_file_obj.each do |deveice_name, bak_file_array|

        for i in 0..new_sort_index.length-1 do
            old_index = new_sort_index[i]
            if bak_file_array.size > old_index
                src_imag_file_name = bak_file_array[old_index]
                extension = File.extname(src_imag_file_name)
                new_name = i.to_s
                if new_name.to_s.size < 2
                    new_name = "0" + new_name
                end

                new_des_file_name = File.join(lang_screenshots_path, deveice_name + "_" + new_name + extension)
                puts new_des_file_name
                FileUtils.mv(src_imag_file_name, new_des_file_name, force:true)
            end
        end
    end

    FileUtils.rm_rf(bacK_lang_screenshots_path) if Dir.exist?(bacK_lang_screenshots_path)


end

#check_attributes(attributes: nil) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 65

def check_attributes(attributes: nil)
	attributes = attributes || {}
	new_attributes = {}
	attributes.each do |key, value|
		if !value.nil? && !value.to_s.empty?
			new_attributes[key] = value
		end
	end

	# puts JSON.pretty_generate(new_attributes)
	return new_attributes
end

#display_type_dir_nameObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 15

def display_type_dir_name

	array =  {
              "APP_IPHONE_35" => "iphone_3.5_",
              "APP_IPHONE_40" => "iphone_4.0_",
              "APP_IPHONE_47" => "iphone_4.7_",
              "APP_IPHONE_55" => "iphone_5.5_",
              "APP_IPHONE_58" => "iphone_5.8_",
              "APP_IPHONE_65" => "iphone_6.5_",
              "APP_IPHONE_67" => "iphone_6.7_",
              "APP_IPAD_97" => "ipad_97_",
              "APP_IPAD_105" => "ipad_105_",
              "APP_IPAD_PRO_129" => "ipad_",
              "APP_IPAD_PRO_3GEN_11" => "ipad_11_",
              "APP_IPAD_PRO_3GEN_129" => "ipadPro129_",
              "APP_IPAD_PRO_6GEN_129" => "ipadPro129_",

              "IMESSAGE_APP_IPHONE_40" => "im_4.0_",
              "IMESSAGE_APP_IPHONE_47" => "im_4.7_",
              "IMESSAGE_APP_IPHONE_55" => "im_5.5_",
              "IMESSAGE_APP_IPHONE_58" => "im_5.8_",
              "IMESSAGE_APP_IPHONE_61" => "im_6.1_",
              "IMESSAGE_APP_IPHONE_65" => "im_6.5_",
              "IMESSAGE_APP_IPHONE_67" => "im_6.7_",
              "IMESSAGE_APP_IPAD_97" => "im_ipad_",
              "IMESSAGE_APP_IPAD_105" => "im_ipad_",
              "IMESSAGE_APP_IPAD_PRO_129" => "im_ipad_",
              "IMESSAGE_APP_IPAD_PRO_3GEN_129" => "im_ipadPro129_",
              "IMESSAGE_APP_IPAD_PRO_3GEN_11" => "im_ipadPro129_",
              "IMESSAGE_APP_IPAD_PRO_6GEN_129" => "im_ipadPro129_",

              "APP_WATCH_SERIES_3" => "watch_3_",
              "APP_WATCH_SERIES_4" => "watch_4_",
              "APP_WATCH_SERIES_7" => "watch_7_",
              "APP_WATCH_ULTRA" => "watch_ul_",

              "APP_DESKTO" => "desktop_"

}

   return array

end

#download_screenshots_exe(file_name: nil, url: nil, over_write: nil) ⇒ Object



943
944
945
946
947
948
949
950
951
952
953
954
955
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 943

def download_screenshots_exe(file_name:nil, url:nil, over_write:nil)

    if !over_write && File.exist?(file_name)
        puts " Existing screenshot #{file_name}"
        return
    end

    puts "Downloading existing screenshot #{file_name}"

    File.binwrite(file_name, URI.open(url).read)
    # File.binwrite(file_name, FastlaneCore::Helper.open_uri(url).read)

end

#fastlane_download_app_info(app: nil, app_itunes_json: nil, app_itunes_dir: nil) ⇒ Object



655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 655

def fastlane_download_app_info(app: nil, app_itunes_json:nil, app_itunes_dir:nil)


    app_info = app.fetch_edit_app_info || app.fetch_live_app_info

	if app_info.primary_category.nil?
		app_itunes_json["app_info"]["primary_category"] = app_info.primary_category
	else
		app_itunes_json["app_info"]["primary_category"] = app_info.primary_category.id
	end

	if app_info.primary_subcategory_one.nil?
		app_itunes_json["app_info"]["primary_subcategory_one"] = app_info.primary_subcategory_one
	else
		app_itunes_json["app_info"]["primary_subcategory_one"] = app_info.primary_subcategory_one.id
	end

	if app_info.primary_subcategory_two.nil?
		app_itunes_json["app_info"]["primary_subcategory_two"] = app_info.primary_subcategory_two
	else
		app_itunes_json["app_info"]["primary_subcategory_two"] = app_info.primary_subcategory_two.id
	end

			if app_info.secondary_category.nil?
		app_itunes_json["app_info"]["secondary_category"] = app_info.secondary_category
	else
		app_itunes_json["app_info"]["secondary_category"] = app_info.secondary_category.id
	end

			if app_info.secondary_subcategory_one.nil?
		app_itunes_json["app_info"]["secondary_subcategory_one"] = app_info.secondary_subcategory_one
	else
		app_itunes_json["app_info"]["secondary_subcategory_one"] = app_info.secondary_subcategory_one.id
	end

			if app_info.secondary_subcategory_two.nil?
		app_itunes_json["app_info"]["secondary_subcategory_two"] = app_info.secondary_subcategory_two
	else
		app_itunes_json["app_info"]["secondary_subcategory_two"] = app_info.secondary_subcategory_two.id
	end

    age_rating_declaration = app_info.fetch_age_rating_declaration
    if !age_rating_declaration.nil?

    	app_itunes_json["app_info"]["app_age_rating"] = app_itunes_json["app_info"]["app_age_rating"] || {}
    	app_itunes_json["app_info"]["app_age_rating"]["alcohol_tobacco_or_drug_use_or_references"] = age_rating_declaration.alcohol_tobacco_or_drug_use_or_references.nil? ? "NONE" : age_rating_declaration.alcohol_tobacco_or_drug_use_or_references
    	app_itunes_json["app_info"]["app_age_rating"]["contests"] = age_rating_declaration.contests.nil? ? "NONE" : age_rating_declaration.contests
    	app_itunes_json["app_info"]["app_age_rating"]["gambling_simulated"] = age_rating_declaration.gambling_simulated.nil? ? "NONE" : age_rating_declaration.gambling_simulated
    	app_itunes_json["app_info"]["app_age_rating"]["medical_or_treatment_information"] = age_rating_declaration.medical_or_treatment_information.nil? ? "NONE" : age_rating_declaration.medical_or_treatment_information
    	app_itunes_json["app_info"]["app_age_rating"]["profanity_or_crude_humor"] = age_rating_declaration.profanity_or_crude_humor.nil? ? "NONE" : age_rating_declaration.profanity_or_crude_humor
    	app_itunes_json["app_info"]["app_age_rating"]["sexual_content_graphic_and_nudity"] = age_rating_declaration.sexual_content_graphic_and_nudity.nil? ? "NONE" : age_rating_declaration.sexual_content_graphic_and_nudity
    	app_itunes_json["app_info"]["app_age_rating"]["sexual_content_or_nudity"] = age_rating_declaration.sexual_content_or_nudity.nil? ? "NONE" : age_rating_declaration.sexual_content_or_nudity
    	app_itunes_json["app_info"]["app_age_rating"]["horror_or_fear_themes"] = age_rating_declaration.horror_or_fear_themes.nil? ? "NONE" : age_rating_declaration.horror_or_fear_themes
    	app_itunes_json["app_info"]["app_age_rating"]["mature_or_suggestive_themes"] = age_rating_declaration.mature_or_suggestive_themes.nil? ? "NONE" : age_rating_declaration.mature_or_suggestive_themes
    	app_itunes_json["app_info"]["app_age_rating"]["violence_cartoon_or_fantasy"] = age_rating_declaration.violence_cartoon_or_fantasy.nil? ? "NONE" : age_rating_declaration.violence_cartoon_or_fantasy
    	app_itunes_json["app_info"]["app_age_rating"]["violence_realistic_prolonged_graphic_or_sadistic"] = age_rating_declaration.violence_realistic_prolonged_graphic_or_sadistic.nil? ? "NONE" : age_rating_declaration.violence_realistic_prolonged_graphic_or_sadistic
    	app_itunes_json["app_info"]["app_age_rating"]["violence_realistic"] = age_rating_declaration.violence_realistic.nil? ? "NONE" : age_rating_declaration.violence_realistic
    	app_itunes_json["app_info"]["app_age_rating"]["gambling"] = age_rating_declaration.gambling.nil? ? false : age_rating_declaration.gambling
    	app_itunes_json["app_info"]["app_age_rating"]["unrestricted_web_access"] = age_rating_declaration.unrestricted_web_access.nil? ? false : age_rating_declaration.unrestricted_web_access
    	app_itunes_json["app_info"]["app_age_rating"]["kids_age_band"] = age_rating_declaration.kids_age_band.nil? ? nil : age_rating_declaration.kids_age_band
    	app_itunes_json["app_info"]["app_age_rating"]["seventeen_plus"] = age_rating_declaration.seventeen_plus.nil? ? false : age_rating_declaration.seventeen_plus
    end













    app_info_localizations = app_info.get_app_info_localizations

    if !app_info_localizations.nil?

    	locales_to_disable = all_languages - app_info_localizations.map(&:locale)

				locales_to_disable.each do | lang |
      app_itunes_json["app_info"]["app_info_localization"].delete(lang)
				end


        app_info_localizations.each do |app_info_localization|

        	lang = app_info_localization.locale

            app_itunes_json["app_info"]["app_info_localization"][lang] = {}
            app_info_localization_data = app_itunes_json["app_info"]["app_info_localization"][lang]

            app_info_localization_data["name"] = app_info_localization.name.nil? ? "" : app_info_localization.name
            app_info_localization_data["subtitle"] = app_info_localization.subtitle.nil? ? "" : app_info_localization.subtitle
            app_info_localization_data["privacy_policy_url"] = app_info_localization.privacy_policy_url.nil? ? "" : app_info_localization.privacy_policy_url
            app_info_localization_data["privacy_choices_url"] = app_info_localization.privacy_choices_url.nil? ? "" : app_info_localization.privacy_choices_url
            app_info_localization_data["privacy_policy_text"] = app_info_localization.privacy_policy_text.nil? ? "" : app_info_localization.privacy_policy_text

        end
    end


end

#fastlane_download_app_screenshot_exe(folder_path, localization, over_write: false) ⇒ Object



894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 894

def fastlane_download_app_screenshot_exe(folder_path, localization, over_write:false)
	language = localization.locale

	screenshot_sets = localization.get_app_screenshot_sets
	screenshot_sets.each do |screenshot_set|

		# If the screen shot is for an appleTV we need to store it in a way that we'll know it's an appleTV
		# screen shot later as the screen size is the same as an iPhone 6 Plus in landscape.
		if screenshot_set.apple_tv?
		    containing_folder = File.join(folder_path, "appleTV", language)
		else
		    containing_folder = File.join(folder_path, language)
		end

		if screenshot_set.imessage?
		    containing_folder = File.join(folder_path, "iMessage", language)
		end

		begin
		    FileUtils.mkdir_p(containing_folder)
		rescue
		# if it's already there
		end

              puts "======== #{screenshot_set.screenshot_display_type}"
		dir_name = display_type_dir_name[screenshot_set.screenshot_display_type]


		screenshot_set.app_screenshots.each_with_index do |screenshot, index|
                  name_index = index
                  if index < 10
                      name_index = "0" + index.to_s
                  end
                  file_name = [dir_name, name_index].join()


                  original_file_extension = File.extname(screenshot.file_name).strip.downcase[1..-1]
                  file_name += "." + original_file_extension

                  url = screenshot.image_asset_url(type: original_file_extension)
                  next if url.nil?


                  path = File.join(containing_folder, file_name)
                  download_screenshots_exe(file_name:path, url:url, over_write:over_write)
		end
	end
end

#fastlane_download_app_screenshots(app_version_info: nil, platform: nil, app_screenshots_dir: nil, over_write: false) ⇒ Object



871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 871

def fastlane_download_app_screenshots(app_version_info: nil, platform:nil, app_screenshots_dir:nil,  over_write:false)


    screenshots_platform_path = File.join(app_screenshots_dir, platform.downcase)
			begin
				FileUtils.mkdir_p(File.join(screenshots_platform_path))
			rescue
# if it's already there
			end


			app_version_info_localizations = app_version_info.get_app_store_version_localizations

			threads = []
			app_version_info_localizations.each do |app_version_info_localization|
				threads << Thread.new do
				  fastlane_download_app_screenshot_exe(screenshots_platform_path, app_version_info_localization, over_write:over_write)
				end
			end
			threads.each(&:join)

end

#fastlane_download_app_version_info(app_version_info: nil, platform: nil, app_itunes_json: nil, app_itunes_dir: nil) ⇒ Object



760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 760

def fastlane_download_app_version_info(app_version_info: nil, platform:nil, app_itunes_json:nil, app_itunes_dir:nil)

     = File.join(app_itunes_dir, platform.downcase)
    if !File.exist?()
        FileUtils.mkdir_p()
    end
    app_itunes_json["app_edit_version_info"][platform] = {}
    app_itunes_json["app_edit_version_info"][platform]["app_review_info"] = {}

    app_itunes_json["app_edit_version_info"][platform]["version_string"] = app_version_info.version_string.nil? ? "" : app_version_info.version_string
    app_itunes_json["app_edit_version_info"][platform]["copyright"] = app_version_info.copyright.nil? ? "" : app_version_info.copyright
    app_itunes_json["app_edit_version_info"][platform]["release_type"] = app_version_info.release_type.nil? ? "" : app_version_info.release_type



    app_store_review_data = app_itunes_json["app_edit_version_info"][platform]["app_review_info"]
    app_store_review_detail = begin
                                app_version_info.fetch_app_store_review_detail
                                rescue => error
                                    puts "no review detail !!!"
                                end # errors if doesn't exist

    if !app_store_review_detail.nil?
        app_store_review_data["contact_first_name"] = app_store_review_detail.contact_first_name
        app_store_review_data["contact_last_name"] = app_store_review_detail.contact_last_name
        app_store_review_data["contact_phone"] = app_store_review_detail.contact_phone
        app_store_review_data["contact_email"] = app_store_review_detail.contact_email
        app_store_review_data["demo_account_name"] = app_store_review_detail.
        app_store_review_data["demo_account_password"] = app_store_review_detail.
        app_store_review_data["demo_account_required"] = app_store_review_detail.
        app_store_review_data["notes"] = app_store_review_detail.notes
    else
        app_store_review_data["contact_first_name"] =  ""
        app_store_review_data["contact_last_name"] =  ""
        app_store_review_data["contact_phone"] =  ""
        app_store_review_data["contact_email"] =  ""
        app_store_review_data["demo_account_name"] =  ""
        app_store_review_data["demo_account_password"] =  ""
        app_store_review_data["demo_account_required"] = false
        app_store_review_data["notes"] = ""
    end

	app_itunes_json["app_edit_version_info"][platform]["app_version_info_localization"] = app_itunes_json["app_edit_version_info"][platform]["app_version_info_localization"] || {}

	# app_itunes_json["app_edit_version_info"][platform]["app_version_screenshots"] = app_itunes_json["app_edit_version_info"][platform]["app_version_screenshots"] || {}
	# app_itunes_json["app_edit_version_info"][platform]["app_version_previews"] = app_itunes_json["app_edit_version_info"][platform]["app_version_previews"] || {}

	app_version_info_localizations = app_version_info.get_app_store_version_localizations(includes: 'appPreviewSets,appScreenshotSets')

			locales_to_disable = all_languages - app_version_info_localizations.map(&:locale)

			locales_to_disable.each do | lang |
         = File.join(, lang)
     if File.exist?()
         FileUtils.rm_rf()
     end

     app_itunes_json["app_edit_version_info"][platform]["app_version_info_localization"].delete(lang)
     # app_itunes_json["app_edit_version_info"][platform]["app_version_screenshots"].delete(lang)
     # app_itunes_json["app_edit_version_info"][platform]["app_version_previews"].delete(lang)
			end

			if !app_version_info_localizations.nil?

			    app_version_info_localizations.each do |app_version_info_localization|

lang = app_version_info_localization.locale

            lang_txt_path = File.join(, lang)

      if !File.exist?(lang_txt_path)
          FileUtils.mkdir_p(lang_txt_path)
      end

   app_itunes_json["app_edit_version_info"][platform]["app_version_info_localization"][lang] = app_itunes_json["app_edit_version_info"][platform]["app_version_info_localization"][lang] || {}

  	localization_data = app_itunes_json["app_edit_version_info"][platform]["app_version_info_localization"][lang]


					localization_data["description"] = app_version_info_localization.description
					localization_data["keywords"] = app_version_info_localization.keywords
					localization_data["support_url"] = app_version_info_localization.support_url
					localization_data["marketing_url"] = app_version_info_localization.marketing_url
					localization_data["promotional_text"] = app_version_info_localization.promotional_text
					localization_data["whats_new"] = app_version_info_localization.whats_new


            write_app_version_info_localization_to_txt(lang_txt_path: lang_txt_path, key_name:"description", key_value:localization_data["description"])
            write_app_version_info_localization_to_txt(lang_txt_path: lang_txt_path, key_name:"keywords", key_value:localization_data["keywords"])
            write_app_version_info_localization_to_txt(lang_txt_path: lang_txt_path, key_name:"support_url", key_value:localization_data["support_url"])
            write_app_version_info_localization_to_txt(lang_txt_path: lang_txt_path, key_name:"marketing_url", key_value:localization_data["marketing_url"])
            write_app_version_info_localization_to_txt(lang_txt_path: lang_txt_path, key_name:"promotional_text", key_value:localization_data["promotional_text"])
            write_app_version_info_localization_to_txt(lang_txt_path: lang_txt_path, key_name:"whats_new", key_value:localization_data["whats_new"])

   # app_itunes_json["app_edit_version_info"][platform]["app_version_screenshots"][app_version_info_localization.locale] = app_itunes_json["app_edit_version_info"][platform]["app_version_screenshots"][app_version_info_localization.locale] || []
   # app_itunes_json["app_edit_version_info"][platform]["app_version_previews"][app_version_info_localization.locale] = app_itunes_json["app_edit_version_info"][platform]["app_version_previews"][app_version_info_localization.locale] || []
			    end

			end

end

#fastlane_login(apple_id: nil) ⇒ Object



78
79
80
81
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 78

def (apple_id:nil)
	Spaceship::Tunes.(apple_id.to_s)
	Spaceship::Tunes.select_team
end

#fastlane_process_lang_screenshots(lang_screenshots_path: nil) ⇒ Object



526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 526

def fastlane_process_lang_screenshots(lang_screenshots_path:nil)

    valid_file_extensions = ['png', 'PNG', 'jpg', 'JPG', 'jpeg', 'JPEG']


    #检查是否区分iPad 2和iPad Pro
    ipad_dir_array= []
    all_device_size = Deliver::AppScreenshot.devices
    Dir.glob(File.join(lang_screenshots_path, "*")).each do |image_dir_path|
        image_dir_basename = File.basename(image_dir_path)
        # puts "image_dir_basename:#{image_dir_basename}"
        if File.directory?(image_dir_path) && ![".", ".."].include?(image_dir_basename)
            valide_pic_num = 0
            Dir.foreach(image_dir_path) do |file|
                image_full_name = File.join(image_dir_path,  file)
                extname = File.extname(image_full_name).delete('.')
                if valid_file_extensions.include?(extname)
                    img_size = FastImage.size(image_full_name)
                    if all_device_size[Deliver::AppScreenshot::ScreenSize::IOS_IPAD_PRO].include?(img_size)
                        valide_pic_num = valide_pic_num + 1
                    end

                    if valide_pic_num >=1
                        ipad_dir_array << image_dir_basename.to_s.downcase
                        break;
                    end
                end
            end


        end
    end
    if ipad_dir_array.include?("ipadpro3") || ipad_dir_array.include?("ipadpro129") || ipad_dir_array.include?("ipad_6gen")
        # puts "找到ipad pro 3截屏"
    else
        puts lang_screenshots_path
        raise Informative, "iPad 3代截屏没有iPad 2代截屏区分开,请修改iPad截屏目录, iPad 3代截屏目录修改为: ipadpro129"
    end




    Dir.glob(File.join(lang_screenshots_path, "*")).each do |image_dir_path|
        image_dir_basename = File.basename(image_dir_path)
        # puts "处理目录:#{image_dir_path}"
        # puts "basename:#{image_dir_basename}"
        if File.directory?(image_dir_path) && ![".", ".."].include?(image_dir_basename)
            Dir.foreach(image_dir_path) do |file|

                image_full_name = File.join(image_dir_path,  file)
                extname = File.extname(image_full_name).delete('.')
                extension = File.extname(image_full_name)
                base_name = File.basename(image_full_name, extension)
                dest_name = File.join(lang_screenshots_path, file)

                if valid_file_extensions.include?(extname)
                    new_base_name = base_name + extension
                    if base_name.to_s.size < 2
                        new_base_name = "0"+base_name + extension
                    end
                    img_size = FastImage.size(image_full_name)


                    if lang_screenshots_path.include?("/iMessage/") || lang_screenshots_path.include?("/imessage/") || lang_screenshots_path.include?("/IMESSAGE/")

                        all_device_size = Deliver::AppScreenshot.device_messages
                        # puts all_message_device_size

                        if all_device_size[Deliver::AppScreenshot::ScreenSize::IOS_IPAD_PRO_MESSAGES].include?(img_size)
                            if image_dir_basename.to_s.downcase.include?("ipadpro3") || image_dir_basename.to_s.downcase.include?("ipadpro129") || image_dir_basename.to_s.downcase.include?("ipad_6gen")
                                dest_name = File.join(lang_screenshots_path, display_type_dir_name["IMESSAGE_APP_IPAD_PRO_6GEN_129"] + new_base_name)
                            else
                                dest_name = File.join(lang_screenshots_path, display_type_dir_name["IMESSAGE_APP_IPAD_PRO_129"] + new_base_name)
                            end
                        elsif all_device_size[Deliver::AppScreenshot::ScreenSize::IOS_67_MESSAGES].include?(img_size)
                            dest_name = File.join(lang_screenshots_path, display_type_dir_name["IMESSAGE_APP_IPHONE_67"] + new_base_name)
                        elsif all_device_size[Deliver::AppScreenshot::ScreenSize::IOS_65_MESSAGES].include?(img_size)
                            dest_name = File.join(lang_screenshots_path, display_type_dir_name["IMESSAGE_APP_IPHONE_65"] + new_base_name)
                        elsif all_device_size[Deliver::AppScreenshot::ScreenSize::IOS_55_MESSAGES].include?(img_size)
                            dest_name = File.join(lang_screenshots_path, display_type_dir_name["IMESSAGE_APP_IPHONE_55"] + new_base_name)
                        end

                    else
                        all_device_size = Deliver::AppScreenshot.devices
                        # puts all_device_size
                        if all_device_size[Deliver::AppScreenshot::ScreenSize::IOS_IPAD_PRO].include?(img_size)
                            if image_dir_basename.to_s.downcase.include?("ipadpro3") || image_dir_basename.to_s.downcase.include?("ipadpro129") || image_dir_basename.to_s.downcase.include?("ipad_6gen")
                                dest_name = File.join(lang_screenshots_path, display_type_dir_name["APP_IPAD_PRO_6GEN_129"] + new_base_name)
                            else
                                dest_name = File.join(lang_screenshots_path, display_type_dir_name["APP_IPAD_PRO_129"] + new_base_name)
                            end
                        elsif all_device_size[Deliver::AppScreenshot::ScreenSize::IOS_67].include?(img_size)
                            dest_name = File.join(lang_screenshots_path, display_type_dir_name["APP_IPHONE_67"] + new_base_name)
                        elsif all_device_size[Deliver::AppScreenshot::ScreenSize::IOS_65].include?(img_size)
                            dest_name = File.join(lang_screenshots_path, display_type_dir_name["APP_IPHONE_65"] + new_base_name)
                        elsif all_device_size[Deliver::AppScreenshot::ScreenSize::IOS_55].include?(img_size)
                            dest_name = File.join(lang_screenshots_path, display_type_dir_name["APP_IPHONE_55"] + new_base_name)
                        end
                    end

                    # if (img_size[0] == 1290 && img_size[1] == 2796) || (img_size[0] == 2796 && img_size[1] == 1290)
                    #     dest_name = File.join(lang_screenshots_path, display_type_dir_name["APP_IPHONE_67"] + new_base_name)
                    # end
                    # if (img_size[0] == 1242 && img_size[1] == 2688) || (img_size[0] == 2688 && img_size[1] == 1242) || (img_size[0] == 1284 && img_size[1] == 2778) || (img_size[0] == 2778 && img_size[1] == 1284)
                    #     dest_name = File.join(lang_screenshots_path, display_type_dir_name["APP_IPHONE_65"] + new_base_name)
                    # end

                    # if (img_size[0] == 1242 && img_size[1] == 2208) || (img_size[0] == 2208 && img_size[1] == 1242)
                    #     dest_name = File.join(lang_screenshots_path, display_type_dir_name["APP_IPHONE_55"] + new_base_name)
                    # end

                    FileUtils.mv(image_full_name, dest_name, force:true)
                end

            end

            FileUtils.rm_rf(image_dir_path)
        end

    end




end

#fastlane_update_app_info_localizations(app: nil, app_itunes_json: nil) ⇒ Object



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 244

def fastlane_update_app_info_localizations(app: nil, app_itunes_json:nil)

			app_info = app.fetch_edit_app_info

       sleep(3)

       begin
           puts
           puts "更新 App Info Localizations..."
           app_info_localization_attributes = app_itunes_json['app_info']["app_info_localization"]
           app_info_localizations = verify_app_info_localizations(app_info:app_info, app_info_localization_attributes:app_info_localization_attributes)
           update_app_info_localizations(app_info_localizations:app_info_localizations, app_info_localization_attributes:app_info_localization_attributes)
           update_app_info_localizations(app_info_localizations:app_info_localizations, app_info_localization_attributes:app_info_localization_attributes)
           puts "更新App Info Localizations 成功 !!!"
       rescue => error
           puts "更新App Info Localizations 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
           puts error
       end


end

#fastlane_update_app_info_metadata(app: nil, app_itunes_json: nil) ⇒ Object



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 215

def (app: nil, app_itunes_json:nil)


    app_info = app.fetch_edit_app_info

    begin
        puts "\n\n更新 Category ..."
        update_app_categories(app_info:app_info, app_info_data:app_itunes_json["app_info"])
        puts "更新 Category 成功 !!!"
    rescue => error
        puts "更新 Category 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
        puts error
    end

    if !app_age_rating_attributes = app_itunes_json["app_info"]["app_age_rating"].nil?
        begin
            puts "\n\n更新 Age Rating ..."
            app_age_rating_attributes = app_itunes_json["app_info"]["app_age_rating"]
            update_age_rating(app_info:app_info, age_rate_config:app_age_rating_attributes)
            puts "更新 Age Rating 成功 !!!"
        rescue => error
            puts "更新 Age Rating 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
            puts error
        end
    end

end

#fastlane_update_app_metadata(app: nil, app_itunes_json: nil) ⇒ Object



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 159

def (app: nil, app_itunes_json:nil)

          begin
              puts "\n\n更新 app价格 ..."
              attributes = {}
              attributes[:availableInNewTerritories] = true
              territory_ids = Spaceship::ConnectAPI::Territory.all.map(&:id)
              price_tier = "0"
              app.update(attributes: attributes, app_price_tier_id: price_tier, territory_ids: territory_ids)
              puts "更新 app价格 成功 !!!"
          rescue => error
              puts "更新 app价格 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
              puts error
          end



          if !app_itunes_json['content_rights_declaration'].nil?
              begin
                  puts "\n\n更新 Third Content ..."
                  app.update(attributes:{"contentRightsDeclaration": app_itunes_json['content_rights_declaration']})
                  puts "更新 Third Content 成功 !!!"
              rescue => error
                  puts "更新 Third Content 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
                  puts error
              end
          end

          if !app_itunes_json['primary_locale'].nil?
              begin
                  puts "\n\n更新 Primary Language ..."
                  app.update(attributes:{"primaryLocale": app_itunes_json['primary_locale']})
                  puts "更新 Primary Language 成功 !!!"
              rescue => error
                  puts "更新 Primary Language 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
                  puts error
              end
          end


          if !app_itunes_json['privacy_data'].nil?
              # begin
                  puts "\n\n更新 Privacy Usage Data ..."
                  app_privacy_data = app_itunes_json['privacy_data']
                  update_privacy_useagedata(app: app, app_privacy_data:app_privacy_data)

              # rescue => error
              #     puts "更新 Privacy Usage Data 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
              #     puts error
              # end
          end


end

#fastlane_update_app_version_info_metadata(app: nil, platform: nil, app_itunes_json: nil) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 83

def (app: nil, platform:nil, app_itunes_json:nil)


			begin
           puts "\n\n更新 Version ..."
           app_version = app_itunes_json["app_edit_version_info"][platform]["version_string"]
           app.ensure_version!(app_version)
           puts "更新 Version 成功 !!!"
       rescue => error
           puts "更新 Version 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
           puts error
       end


       app_edit_version_info = app.get_edit_app_store_version(platform: platform, includes: 'appStoreVersionSubmission,build,appStoreVersionPhasedRelease,appStoreVersionLocalizations')
       app_live_version_info = app.get_live_app_store_version(platform: platform)

       if !app_itunes_json["app_edit_version_info"][platform]['app_version_info_localization'].nil?
           begin
               puts
               puts "更新 App Version Localizations..."
               version_info_localization_attributes = app_itunes_json["app_edit_version_info"][platform]['app_version_info_localization']
               version_info_localizations = verify_app_version_info_localizations(app_version_info:app_edit_version_info, version_info_localization_attributes:version_info_localization_attributes)
               update_version_info_localizations(version_info_localizations:version_info_localizations, version_info_localization_attributes:version_info_localization_attributes, app_live_version_info:app_live_version_info)
               puts "更新App Version Localizations 成功 !!!"
           rescue => error
               puts "更新App Version Localizations 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
               puts error
           end
       end



       if !app_itunes_json["app_edit_version_info"][platform]['copyright'].nil?
           begin
               puts "\n\n更新 Copy Right..."
               app_edit_version_info.update(attributes: { "copyright": app_itunes_json["app_edit_version_info"][platform]['copyright']} )
               puts "更新 Copy Right 成功 !!!"
           rescue => error
               puts "更新 Copy Right 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
               puts error
           end
       end

       if !app_itunes_json["app_edit_version_info"][platform]['release_type'].nil?
           begin
               puts "\n\n更新 ReleaseType ..."
               app_edit_version_info.update(attributes: { "releaseType": app_itunes_json["app_edit_version_info"][platform]['release_type'] })
               puts "更新 ReleaseType 成功 !!!"
           rescue => error
               puts "更新 ReleaseType 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
               puts error
           end
       end

       if !app_itunes_json["app_edit_version_info"][platform]['app_review_info'].nil?
           begin
               puts "\n\n更新 Review Info ..."
               notes_file = "app_" + platform + "_review_notes.txt"
               app_review_attributes = {}
               app_review_data = app_itunes_json["app_edit_version_info"][platform]['app_review_info']
               app_review_data.each do |key, value|
                   attributes_key =  camel_case_lower(string:key)
                   app_review_attributes[attributes_key] = value
               end
               update_review_info(app_version_info:app_edit_version_info, app_review_attributes:app_review_attributes)
               puts "更新 Review Info 成功 !!!"
           rescue => error
               puts "更新 Review Info 失败 !!! ===============+++++++============= 失败 !!!失败 !!!"
               puts error
           end
       end


end

#update_age_rating(app_info: nil, age_rate_config: nil) ⇒ Object



397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 397

def update_age_rating(app_info:nil, age_rate_config:nil)
    declaration = app_info.fetch_age_rating_declaration unless app_info.nil?
    age_rate_attributes = {}

    age_rate_config.each do |key, value|

    	attributes_key =  camel_case_lower(string:key)
    	age_rate_attributes[attributes_key] = value
    end

    declaration.update(attributes: age_rate_attributes)

end

#update_app_categories(app_info: nil, app_info_data: nil) ⇒ Object



353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 353

def update_app_categories(app_info:nil, app_info_data:nil)


       if !app_info_data.nil?
           category_id_map = {}

           if !app_info_data["primary_category"].nil?
               category_id_map[:primary_category_id] = app_info_data["primary_category"]

               if app_info_data["primary_category"].eql?("STICKERS") || app_info_data["primary_category"].eql?("GAMES")
                   category_id_map[:primary_subcategory_one_id] = app_info_data["primary_subcategory_one"]
                   category_id_map[:primary_subcategory_two_id] = app_info_data["primary_subcategory_two"]

               else
                   category_id_map[:primary_subcategory_one_id] = nil
                   category_id_map[:primary_subcategory_two_id] = nil
               end
           end



           if !app_info_data["secondary_category"].nil? && !app_info_data["primary_category"].eql?("STICKERS") && !app_info_data["primary_category"].eql?("GAMES")
               category_id_map[:secondary_category_id] = app_info_data["secondary_category"]
               if app_info_data["secondary_category"].eql?("STICKERS") || app_info_data["secondary_category"].eql?("GAMES")
                   category_id_map[:secondary_subcategory_one_id] = app_info_data["secondary_subcategory_one"]
                   category_id_map[:secondary_subcategory_two_id] = app_info_data["secondary_subcategory_two"]
               else
                   category_id_map[:secondary_subcategory_one_id] = nil
                   category_id_map[:secondary_subcategory_two_id] = nil
               end
           else
               category_id_map[:secondary_category_id] = nil
               category_id_map[:secondary_subcategory_one_id] = nil
               category_id_map[:secondary_subcategory_two_id] = nil
           end

           app_info.update_categories(category_id_map: category_id_map)

       end

end

#update_app_info_localizations(app_info_localizations: nil, app_info_localization_attributes: nil) ⇒ Object



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 443

def update_app_info_localizations(app_info_localizations:nil, app_info_localization_attributes:nil)

    		# Update app info localizations
     app_info_worker = FastlaneCore::QueueWorker.new do |app_info_localization|
       attributes = app_info_localization_attributes[app_info_localization.locale]

       if attributes
       	puts "Uploading app info localized '#{app_info_localization.locale}'"
       	attributes = check_attributes(attributes:attributes)
         	app_info_localization.update(attributes: attributes)
       end
     end
     app_info_worker.batch_enqueue(app_info_localizations)
     app_info_worker.start

end

#update_privacy_useagedata(app: nil, app_privacy_data: nil) ⇒ Object



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 269

def update_privacy_useagedata(app: nil, app_privacy_data:nil)
    all_usages = Spaceship::ConnectAPI::AppDataUsage.all(app_id: app.id, includes: "category,grouping,purpose,dataProtection", limit: 500)

       begin
           all_usages.each(&:delete!)
       rescue => error

       end

       # old_usages_config = {}
       # if !all_usages.nil? && all_usages.size > 0
       #     all_usages.each do |privacy_usage|
       #         if !privacy_usage.category.nil?
       #             category= privacy_usage.category.id
       #             all_usages_config[category] = all_usages_config[category] || {}
       #             all_usages_config[category]["category"] = category
       #             if !privacy_usage.purpose.nil?
       #                 all_usages_config[category]["purposes"] = all_usages_config[category]["purposes"] || []
       #                 all_usages_config[category]["purposes"] << privacy_usage.purpose.id

       #             end
       #             if !privacy_usage.data_protection.nil?
       #                 all_usages_config[category]["data_protections"] = all_usages_config[category]["data_protections"] || []
       #                 all_usages_config[category]["data_protections"] << privacy_usage.data_protection.id
       #             end
       #         end
       #     end
       #     puts old_usages_config
       # end

       # new_usages_config = {}
       # app_privacy_data.each do |usage_config|
       #     category = usage_config["category"]
       #     if category && !category.nil?
       #         new_usages_config[category] = usage_config
       #     end
       # end

       begin
           publish_state = Spaceship::ConnectAPI::AppDataUsagesPublishState.get(app_id: app.id)
           publish_state.publish!
       rescue => error
           puts error
       end


           app_privacy_data.each do |usage_config|
               category = usage_config["category"]
               purposes = usage_config["purposes"] || []
               data_protections = usage_config["data_protections"] || []
               purposes = [nil] if purposes.empty?

               purposes.each do |purpose|
                   data_protections.each do |data_protection|
                           begin
                                   Spaceship::ConnectAPI::AppDataUsage.create(
                                         app_id: app.id,
                                         app_data_usage_category_id: category,
                                         app_data_usage_protection_id: data_protection,
                                         app_data_usage_purpose_id: purpose
                                       )
                           rescue => error

                           end


                   end
               end
           end



       begin

           publish_state = Spaceship::ConnectAPI::AppDataUsagesPublishState.get(app_id: app.id)
           publish_state.publish!
       rescue => error
           puts error
       end


end

#update_review_info(app_version_info: nil, app_review_attributes: nil) ⇒ Object



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 510

def update_review_info(app_version_info:nil, app_review_attributes:nil)
        app_store_review_detail = begin
             app_version_info.fetch_app_store_review_detail
            rescue => error
                puts "no review detail !!!"
            end # errors if doesn't exist

        if app_store_review_detail
            puts "更新review info obj"
            app_store_review_detail.update(attributes: app_review_attributes)
        else
            puts "创建review info obj"
            app_version_info.create_app_store_review_detail(attributes: app_review_attributes)
        end
end

#update_version_info_localizations(version_info_localizations: nil, version_info_localization_attributes: nil, app_live_version_info: nil) ⇒ Object



492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 492

def update_version_info_localizations(version_info_localizations:nil, version_info_localization_attributes:nil, app_live_version_info:nil)
     # Update app store version localizations
     store_version_worker = FastlaneCore::QueueWorker.new do |app_store_version_localization|
       attributes = version_info_localization_attributes[app_store_version_localization.locale]

       if attributes
         	puts "Uploading app version info localized '#{app_store_version_localization.locale}'"
         	attributes = check_attributes(attributes:attributes)
         	if app_live_version_info.nil?
         		attributes.delete("whats_new")
         	end
         	app_store_version_localization.update(attributes: attributes)
       end
     end
     store_version_worker.batch_enqueue(version_info_localizations)
     store_version_worker.start
end

#verify_app_info_localizations(app_info: nil, app_info_localization_attributes: nil) ⇒ Object



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 411

def verify_app_info_localizations(app_info:nil, app_info_localization_attributes:nil)

  localizations = app_info.get_app_info_localizations

  languages = []
  app_info_localization_attributes.each do |lang , attributes |
  	languages << lang
  end

  puts "    存在多语言 #{localizations.map(&:locale).join(', ')}..."
  locales_to_enable = languages - localizations.map(&:locale)

  if locales_to_enable.count > 0


    puts "    创建多语言 #{locales_to_enable.join(', ')}..."

    locales_to_enable.each do |locale|
    	localization_attributes = app_info_localization_attributes[locale]
		app_info.create_app_info_localization(attributes: {
			locale: locale,
			name:localization_attributes["name"]
		})
    end

    localizations = app_info.get_app_info_localizations

  end

  return localizations
end

#verify_app_version_info_localizations(app_version_info: nil, version_info_localization_attributes: nil) ⇒ Object



461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 461

def verify_app_version_info_localizations(app_version_info:nil, version_info_localization_attributes:nil)

	 localizations = app_version_info.get_app_store_version_localizations

   languages = []
version_info_localization_attributes.each do |lang , attributes |
	languages << lang
end

puts "    存在多语言 #{localizations.map(&:locale).join(', ')}..."

   locales_to_enable = languages - localizations.map(&:locale)

   if locales_to_enable.count > 0

     puts "    创建多语言 #{locales_to_enable.join(', ')}..."

     locales_to_enable.each do |locale|
     	localization_attributes = version_info_localization_attributes[locale]
       	app_version_info.create_app_store_version_localization(attributes: {
         	locale: locale
       	})
     end

     localizations = app_version_info.get_app_store_version_localizations
   end

   return localizations
end

#write_app_version_info_localization_to_txt(lang_txt_path: nil, key_name: nil, key_value: nil) ⇒ Object



863
864
865
866
867
868
869
# File 'lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb', line 863

def write_app_version_info_localization_to_txt(lang_txt_path: nil, key_name:nil, key_value:nil)
    key_name_file = File.join(lang_txt_path, key_name +".txt")
    File.open(key_name_file, "w") do |file|
        file.write(key_value)
        file.close
    end
end