Class: Fastlane::Actions::CheckTranslationProgressAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::CheckTranslationProgressAction
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
Class Method Summary collapse
-
.check_results(under_threshold_langs:, threshold:, skip_confirm:) ⇒ Object
Report the status of the translations and verify whether to abort or not.
-
.check_translations(glotpress_url:, language_codes:, abort_on_violations:, threshold:) ⇒ Array
Check the status of the translations and returns the list of violations.
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
140 141 142 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb', line 140 def self. ['Automattic'] end |
.available_options ⇒ Object
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 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb', line 106 def self. [ FastlaneCore::ConfigItem.new(key: :glotpress_url, env_name: 'FL_CHECK_TRANSLATION_PROGRESS_GLOTPRESS_URL', description: 'URL to the GlotPress project', type: String), FastlaneCore::ConfigItem.new(key: :language_codes, env_name: 'FL_CHECK_TRANSLATION_PROGRESS_LANGUAGE_CODES', description: 'The list of the codes of the languages to check', type: Array, optional: true, # Default to Mag16. default_value: 'ar de es fr he id it ja ko nl pt-br ru sv tr zh-cn zh-tw'.split), FastlaneCore::ConfigItem.new(key: :min_acceptable_translation_percentage, env_name: 'FL_CHECK_TRANSLATION_PROGRESS_MIN_ACCEPTABLE_TRANSLATION_PERCENTAGE', description: 'The threshold under which an error is raised', type: Integer, optional: true, default_value: 100), FastlaneCore::ConfigItem.new(key: :abort_on_violations, env_name: 'FL_CHECK_TRANSLATION_ABORT_ON_VIOLATIONS', description: 'Should we abort with a global error if any violations are found?', optional: true, default_value: true, type: Boolean), FastlaneCore::ConfigItem.new(key: :skip_confirm, env_name: 'FL_CHECK_TRANSLATION_SKIP_CONFIRM', description: 'Move ahead without requesting confirmation if violations are found. Only works if "abort_on_violations" is disabled', optional: true, default_value: false, type: Boolean), ] end |
.check_results(under_threshold_langs:, threshold:, skip_confirm:) ⇒ Object
Report the status of the translations and verify whether to abort or not
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb', line 77 def self.check_results(under_threshold_langs:, threshold:, skip_confirm:) = "The translations for the following languages are below the #{threshold}% threshold:\n" under_threshold_langs.each do |lang| << " - #{lang[:lang]} is at #{lang[:progress]}%.\n" end if skip_confirm UI.important() elsif UI.interactive? UI.('Aborted by user!') unless UI.confirm("#{}Do you want to continue?") else UI.() end end |
.check_translations(glotpress_url:, language_codes:, abort_on_violations:, threshold:) ⇒ Array
Check the status of the translations and returns the list of violations
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb', line 38 def self.check_translations(glotpress_url:, language_codes:, abort_on_violations:, threshold:) under_threshold_langs = [] data = begin Fastlane::Helper::GlotPressHelper.get_translation_status_data(glotpress_url: glotpress_url) rescue StandardError nil end UI.("Can't retrieve data from #{glotpress_url}") if data.nil? || data.empty? language_codes.each do |language_code| UI.("> Getting translation status for #{language_code}") progress = begin Fastlane::Helper::GlotPressHelper.get_translation_status( data: data, language_code: language_code ) rescue StandardError -1 end if abort_on_violations UI.("Can't get data for language #{language_code}") if progress == -1 UI.("#{language_code} is translated #{progress}% which is under the required #{threshold}%.") if progress < threshold end UI.("Language #{language_code} is #{progress}% translated.") under_threshold_langs.push({ lang: language_code, progress: progress }) if progress < threshold end under_threshold_langs end |
.description ⇒ Object
97 98 99 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb', line 97 def self.description 'Raises an error if the translation percentage is lower than the provided threshold' end |
.details ⇒ Object
101 102 103 104 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb', line 101 def self.details 'This actions checks the current status of the translations on GlotPress ' \ 'and raises an error if it\'s below the provided threshold' end |
.is_supported?(platform) ⇒ Boolean
144 145 146 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb', line 144 def self.is_supported?(platform) true end |
.run(params) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb', line 6 def self.run(params) require_relative '../../helper/glotpress_helper' UI.('Checking translations status...') under_threshold_langs = check_translations( glotpress_url: params[:glotpress_url], language_codes: params[:language_codes], abort_on_violations: params[:abort_on_violations], threshold: params[:min_acceptable_translation_percentage] ) unless under_threshold_langs.empty? check_results( under_threshold_langs: under_threshold_langs, threshold: params[:min_acceptable_translation_percentage], skip_confirm: params[:skip_confirm] ) end UI.success('Done') end |