Class: Fastlane::Actions::LocalizeAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::LocalizeAction
- Defined in:
- lib/fastlane/plugin/localize/actions/localize_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
56 57 58 |
# File 'lib/fastlane/plugin/localize/actions/localize_action.rb', line 56 def self. ["Wolfgang Lutz"] end |
.available_options ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 |
# File 'lib/fastlane/plugin/localize/actions/localize_action.rb', line 69 def self. [ FastlaneCore::ConfigItem.new(key: :localize_project, env_name: "FL_LOCALIZE_PROJECT", # The name of the environment variable description: "The project to localize", # a short description of this parameter is_string: true, # true: verifies the input is a string, false: every kind of value default_value: Helper::LocalizeHelper.getProject(nil).path # the default value if the user didn't provide one ), FastlaneCore::ConfigItem.new(key: :localize_target, env_name: "FL_LOCALIZE_TARGET", # The name of the environment variable description: "The target to localize", # a short description of this parameter is_string: true, # true: verifies the input is a string, false: every kind of value default_value: Helper::LocalizeHelper.getTargetName(nil) # the default value if the user didn't provide one ), FastlaneCore::ConfigItem.new(key: :use_swiftgen, env_name: "FL_LOCALIZE_USE_SWIFTGEN", # The name of the environment variable description: "Localize using Swiftgens L10n ", # a short description of this parameter is_string: false, # true: verifies the input is a string, false: every kind of value default_value: false # the default value if the user didn't provide one ), FastlaneCore::ConfigItem.new(key: :strings_file, env_name: "FL_LOCALIZE_STRINGS_FILE", description: "The stringsfile to write to", is_string: true, # true: verifies the input is a string, false: every kind of value default_value: "Localizable.strings" # the default value if the user didn't provide one, ), FastlaneCore::ConfigItem.new(key: :file_filter, env_name: "FL_LOCALIZE_FILE_FILTER", description: "Filter strings for file paths to ignore, separated by commas", optional: true, is_string: false), FastlaneCore::ConfigItem.new(key: :lint_only, env_name: "FL_LOCALIZE_LINT_ONLY", # The name of the environment variable description: "Only lint and print warnings for unlocalized strings. ", # a short description of this parameter is_string: false, # true: verifies the input is a string, false: every kind of value default_value: false # the default value if the user didn't provide one ), ] end |
.description ⇒ Object
52 53 54 |
# File 'lib/fastlane/plugin/localize/actions/localize_action.rb', line 52 def self.description "Searches the code for extractable strings and allows interactive extraction to .strings file." end |
.details ⇒ Object
63 64 65 66 67 |
# File 'lib/fastlane/plugin/localize/actions/localize_action.rb', line 63 def self.details "Searches the code for extractable strings and allows interactive extraction to .strings file:" "- Whitelists non-extracted strings" "- Support for NSLocalizedString and Swiftgen" end |
.is_supported?(platform) ⇒ Boolean
109 110 111 112 |
# File 'lib/fastlane/plugin/localize/actions/localize_action.rb', line 109 def self.is_supported?(platform) [:ios, :mac].include?(platform) true end |
.return_value ⇒ Object
60 61 |
# File 'lib/fastlane/plugin/localize/actions/localize_action.rb', line 60 def self.return_value end |
.run(params) ⇒ Object
7 8 9 10 11 12 13 14 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 |
# File 'lib/fastlane/plugin/localize/actions/localize_action.rb', line 7 def self.run(params) project = Helper::LocalizeHelper.getProject(params) target = Helper::LocalizeHelper.getTarget(params) files = Helper::LocalizeHelper.codeFiles(target, params) matches = files.flat_map do |file| Helper::LocalizeHelper.stringsFromFile(file) end matchHash = {} matches.each do |match| matchHash[match[0]] = [] unless matchHash[match[0]] != nil matchHash[match[0]] << match end whitelist = Helper::LocalizeHelper.getWhitelist matchHash.keys .map { |match| match.gsub(/^\\"/, "\"").gsub(/\\"$/, "\"") } .reject { |match| whitelist.include? match } .each { |match| if params[:lint_only] puts "warning: #{match} is not localized" else files.flat_map do |file| Helper::LocalizeHelper.showStringOccurrencesFromFile(file, match) end if UI.confirm "Extract #{match}?" key = UI.input "Enter key for localization:" Helper::LocalizeHelper.localize_string(match, key, files, params) else Helper::LocalizeHelper.addToWhitelist(match) end end } end |