fastlane-plugin-localize 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9abc2c961cdbb0dfb43d435da11531ce84445d6
4
- data.tar.gz: 7e560ea153fb1b19fd10da4c506592e5c8de9513
3
+ metadata.gz: 0d2848b503a8c984d68dee0de467000acb43fd99
4
+ data.tar.gz: cc024c972bbc2c5765b06962b52be771018dc4b0
5
5
  SHA512:
6
- metadata.gz: 374ea985d1bfe90ac4b9d3490979781657d3b41ae735af02e1d4a51f7e8ef9b1823868187ba475fc8aae3561de611662d8ee199b86b85135959bd748a8f1a285
7
- data.tar.gz: 705afb57d00e194c0e957876069cfdb39f2fbb1aa29741d5fe38a1fd8bae01a547420706d57a35723ecc2f432507b2805adfc075a0cfa49c68b5ee2783d70660
6
+ metadata.gz: 44b9b787c8ea208be2744af39bf01b409440a0fd5e3fd48f557decf36b8fc20e691a1b47da1a0808b8763373e85f100e649ff991d7ed43e060c91abf86933745
7
+ data.tar.gz: dcd7b63ba83ed9dd415673de0f8d6fa90f88c7d56b359a7f7260e98227e700e2bb66af28e793fe551c9c65a23de56ea8421432dc4d5dc156dae0f276780bbfb4
data/README.md CHANGED
@@ -14,13 +14,38 @@ fastlane add_plugin localize
14
14
 
15
15
  Searches the code for extractable strings and allows interactive extraction to .strings file.
16
16
 
17
- **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
17
+ - Whitelists non-extracted strings for further runs
18
+ - Extracts as `NSLocalizedString` by default
19
+ - Support for [Swiftgen](https://github.com/SwiftGen/SwiftGen) by supplying `use_swiftgen:true`
18
20
 
19
- ## Example
21
+ ![Example Gif](https://github.com/num42/fastlane-plugin-localize/raw/master/Localize.gif)
20
22
 
21
- Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
23
+ ## Run from Commandline
22
24
 
23
- **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
25
+ To show all options:
26
+
27
+ ```bash
28
+ fastlane action localize
29
+ ```
30
+
31
+ Example:
32
+
33
+ ```bash
34
+ fastlane run localize strings_file:"Sources/Base/Supporting Files/en.lproj/Localizable.strings" file_filter:"Swiftgen,Sourcery" use_swiftgen:"true"
35
+ ```
36
+
37
+ ## Run from Fastfile
38
+
39
+ ```ruby
40
+ desc "Search for localizable strings"
41
+ lane :localize_strings do
42
+ localize(
43
+ strings_file: "Sources/Base/Supporting Files/en.lproj/Localizable.strings",
44
+ file_filter: "Swiftgen,Sourcery", # filters files with these words in their path
45
+ use_swiftgen: "true" # remove to use NSLocalizableString instead
46
+ )
47
+ end
48
+ ```
24
49
 
25
50
  ## Run tests for this plugin
26
51
 
@@ -6,7 +6,8 @@ module Fastlane
6
6
  class LocalizeAction < Action
7
7
  def self.run(params)
8
8
  project = Helper::LocalizeHelper.getProject(params)
9
- target = Helper::LocalizeHelper.getTarget(project)
9
+
10
+ target = Helper::LocalizeHelper.getTarget(params)
10
11
 
11
12
  files = Helper::LocalizeHelper.codeFiles(target, params)
12
13
 
@@ -72,6 +73,12 @@ module Fastlane
72
73
  is_string: true, # true: verifies the input is a string, false: every kind of value
73
74
  default_value: Helper::LocalizeHelper.getProject(nil).path # the default value if the user didn't provide one
74
75
  ),
76
+ FastlaneCore::ConfigItem.new(key: :localize_target,
77
+ env_name: "FL_LOCALIZE_TARGET", # The name of the environment variable
78
+ description: "The target to localize", # a short description of this parameter
79
+ is_string: true, # true: verifies the input is a string, false: every kind of value
80
+ default_value: Helper::LocalizeHelper.getTargetName(nil) # the default value if the user didn't provide one
81
+ ),
75
82
  FastlaneCore::ConfigItem.new(key: :use_swiftgen,
76
83
  env_name: "FL_LOCALIZE_USE_SWIFTGEN", # The name of the environment variable
77
84
  description: "Localize using Swiftgens L10n ", # a short description of this parameter
@@ -9,8 +9,7 @@ module Fastlane
9
9
  # as `Helper::LocalizeHelper.your_method`
10
10
  #
11
11
 
12
-
13
- def self.getProject(options)
12
+ def self.getProjectPath(options)
14
13
  projectPath = nil
15
14
 
16
15
  unless options.nil?
@@ -29,26 +28,44 @@ module Fastlane
29
28
  fail "no xcodeproject found"
30
29
  end
31
30
 
32
- project = Xcodeproj::Project.open(projectPath)
31
+ projectPath
32
+ end
33
+
34
+ def self.getProject(options)
35
+
36
+ project = Xcodeproj::Project.open(self.getProjectPath(options))
33
37
 
34
38
  project
35
39
  end
36
40
 
37
- def self.getTarget(project)
41
+ def self.getTargetName(options)
42
+ project = self.getProject(options)
43
+
38
44
  targetName = nil
39
45
 
40
- # if options[:localize_target].nil?
41
- # targetName = ENV["TARGETNAME"]
42
- # end
46
+ unless options.nil?
47
+ targetName = options[:localize_target]
48
+ end
43
49
 
44
50
  if targetName.nil?
45
- targetName = project.targets.first.name
51
+ targetName = ENV["TARGET_NAME"]
52
+ end
53
+
54
+ if targetName.nil?
55
+ targetName = project.targets.map { |target| target.name.to_s }.first
46
56
  end
47
57
 
48
58
  if targetName.nil?
49
59
  fail "no target found"
50
60
  end
51
61
 
62
+ targetName
63
+ end
64
+
65
+ def self.getTarget(options)
66
+ project = self.getProject(options)
67
+ targetName = self.getTargetName(options)
68
+
52
69
  target = project.targets.select { |target| target.name.eql? targetName }.first
53
70
 
54
71
  if target.nil?
@@ -60,7 +77,12 @@ module Fastlane
60
77
 
61
78
  def self.codeFiles(target, options)
62
79
 
63
- filter = options[:file_filter].split(",")
80
+ if options[:file_filter].nil?
81
+ filter = []
82
+ else
83
+ filter = ( options[:file_filter]).split(",")
84
+ end
85
+
64
86
 
65
87
  codeFiles = target.source_build_phase.files.to_a.map do |pbx_build_file|
66
88
  pbx_build_file.file_ref.real_path.to_s
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Localize
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-localize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wolfgang Lutz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-19 00:00:00.000000000 Z
11
+ date: 2018-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry