Class: Fastlane::Actions::AnLocalizeLibsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



23
24
25
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb', line 23

def self.authors
  ['Automattic']
end

.available_optionsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb', line 34

def self.available_options
  libs_hash_description = <<~KEYS
    - `:library`: The library display name.
    - `:strings_path`: The path to the `strings.xml` file of the library.
    - `:exclusions`: An optional `Array` of string keys to exclude from merging.
    - `:source_id`: An optional `String` which will be added as the `a8c-src-lib` XML attribute
      to strings coming from this library, to help identify their source in the merged file.
    - `:add_ignore_attr`: If set to true, will add `tools:ignore="UnusedResources"` to merged strings.
  KEYS
  [
    FastlaneCore::ConfigItem.new(key: :app_strings_path,
                                 description: 'The path of the main strings file',
                                 optional: false,
                                 type: String),
    # The name of this parameter is a bit misleading due to legacy. In practice it's expected to be an Array of Hashes, each describing a library to merge.
    # See `Fastlane::Helper::Android::LocalizeHelper.merge_lib`'s YARD doc for more details on the keys expected for each Hash.
    FastlaneCore::ConfigItem.new(key: :libs_strings_path,
                                 env_name: 'LOCALIZE_LIBS_STRINGS_PATH',
                                 description: "The list of libs to merge. Each item in the provided array must be a Hash with the following keys:\n#{libs_hash_description}",
                                 optional: false,
                                 type: Array),
  ]
end

.descriptionObject



19
20
21
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb', line 19

def self.description
  'Merges the strings to be localised from the libs into the main application file'
end

.detailsObject



30
31
32
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb', line 30

def self.details
  'Merges the strings to be localised from the libs into the main application file'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb', line 58

def self.is_supported?(platform)
  platform == :android
end

.return_valueObject



27
28
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb', line 27

def self.return_value
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb', line 7

def self.run(params)
  main_strings_path = params[:app_strings_path]
  libraries_strings_path = params[:libs_strings_path]

  any_changes = false
  libraries_strings_path.each do |lib|
    (any_changes = Fastlane::Helper::Android::LocalizeHelper.merge_lib(main_strings_path, lib)) || any_changes
  end

  UI.message("Changes have been applied to #{main_strings_path}. Please, verify it!") if any_changes
end