Skip to content

Commit 7ea4ed0

Browse files
authored
Merge pull request #10 from scribd/mwayne/skip-lang-detection
Mwayne/skip lang detection
2 parents 00b5ec5 + d230614 commit 7ea4ed0

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

deliver/lib/deliver/options.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,12 @@ def self.available_options
460460
type: Boolean,
461461
optional: true,
462462
default_value: true),
463+
FastlaneCore::ConfigItem.new(key: :skip_language_detection,
464+
env_name: "SKIP_LANGUAGE_DETECTION",
465+
description: "Skip language detection in App Store Connect and use the languages specified in the languages param",
466+
type: Boolean,
467+
optional: true,
468+
default_value: false),
463469

464470
# internal
465471
FastlaneCore::ConfigItem.new(key: :app,

deliver/lib/deliver/upload_metadata.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ def upload
9494

9595
enabled_languages = detect_languages
9696

97-
app_store_version_localizations = verify_available_version_languages!(app, enabled_languages) unless options[:edit_live]
9897
app_info = fetch_edit_app_info(app)
99-
app_info_localizations = verify_available_info_languages!(app, app_info, enabled_languages) unless options[:edit_live] || !updating_localized_app_info?(app, app_info)
98+
app_store_version_localizations = nil
99+
app_info_localizations = nil
100100

101101
if options[:edit_live]
102102
# not all values are editable when using live_version
@@ -120,6 +120,23 @@ def upload
120120
non_localised_options = NON_LOCALISED_VERSION_VALUES.keys
121121
end
122122

123+
unless options[:edit_live]
124+
if options[:skip_language_detection]
125+
# Do not create/enable additional locales; use what already exists on ASC
126+
app_store_version_localizations = version.get_app_store_version_localizations
127+
else
128+
app_store_version_localizations = verify_available_version_languages!(app, enabled_languages)
129+
end
130+
131+
if updating_localized_app_info?(app, app_info)
132+
if options[:skip_language_detection]
133+
app_info_localizations = app_info&.get_app_info_localizations
134+
else
135+
app_info_localizations = verify_available_info_languages!(app, app_info, enabled_languages)
136+
end
137+
end
138+
end
139+
123140
# Needed for to filter out release notes from being sent up
124141
number_of_versions = Spaceship::ConnectAPI.get_app_store_versions(
125142
app_id: app.id,

pilot/lib/pilot/build_manager.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ def update_localized_app_review(build, info_by_lang, default_info: nil)
528528
default_info = info_by_lang.delete(:default)
529529
end
530530

531+
allowed = allowed_locales
532+
info_by_lang.select! { |locale, _| allowed.include?(locale.to_s) } if allowed
533+
531534
# Initialize hash of lang codes with info_by_lang keys
532535
localizations_by_lang = {}
533536
info_by_lang.each_key do |key|
@@ -542,6 +545,7 @@ def update_localized_app_review(build, info_by_lang, default_info: nil)
542545

543546
# Create or update localized app review info
544547
localizations_by_lang.each do |lang_code, localization|
548+
next if allowed && !allowed.include?(lang_code.to_s)
545549
info = info_by_lang[lang_code]
546550

547551
info = default_info unless info
@@ -574,6 +578,9 @@ def update_localized_build_review(build, info_by_lang, default_info: nil)
574578
default_info = info_by_lang.delete(:default)
575579
end
576580

581+
allowed = allowed_locales
582+
info_by_lang.select! { |locale, _| allowed.include?(locale.to_s) } if allowed
583+
577584
# Initialize hash of lang codes with info_by_lang keys
578585
localizations_by_lang = {}
579586
info_by_lang.each_key do |key|
@@ -588,13 +595,23 @@ def update_localized_build_review(build, info_by_lang, default_info: nil)
588595

589596
# Create or update localized app review info
590597
localizations_by_lang.each do |lang_code, localization|
598+
next if allowed && !allowed.include?(lang_code.to_s)
591599
info = info_by_lang[lang_code]
592600

593601
info = default_info unless info
594602
update_localized_build_review_for_lang(build, localization, lang_code, info) if info
595603
end
596604
end
597605

606+
def allowed_locales
607+
langs = config[:languages]
608+
langs ||= ENV["LANGUAGES"]
609+
return nil unless langs
610+
611+
langs = langs.split(",") unless langs.kind_of?(Array)
612+
langs.map { |l| l.to_s.strip }.reject(&:empty?)
613+
end
614+
598615
def update_localized_build_review_for_lang(build, localization, locale, info)
599616
attributes = {}
600617
attributes[:whatsNew] = self.class.sanitize_changelog(info[:whats_new]) if info.key?(:whats_new)

pilot/lib/pilot/options.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ def self.available_options
154154
values.keys.each { |value| UI.user_error!("Invalid key '#{value}'") unless valid_keys.include?(value.to_s) }
155155
end
156156
end),
157+
FastlaneCore::ConfigItem.new(key: :languages,
158+
type: Array,
159+
env_name: "LANGUAGES",
160+
description: "List of locales permitted for localized build/app info (e.g. en-US,de-DE). If set, Pilot will ignore other locales when updating localized beta metadata",
161+
optional: true),
157162
FastlaneCore::ConfigItem.new(key: :changelog,
158163
short_option: "-w",
159164
optional: true,

0 commit comments

Comments
 (0)