fastlane-plugin-google_sheet_localize 0.3.05 → 0.3.13

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
  SHA256:
3
- metadata.gz: 1e04803161feae7160efc0cf2a6ede75d3da00289aff36c8e62ab039575ddd9a
4
- data.tar.gz: 6b5aca1a35a1aa1c7c6db035db442d863d3c08bcdadfd21a9d132c9f10f82e14
3
+ metadata.gz: de5986abc705571310d0e2e91484f3ec35664149a0f69822ea56667fa8ce0d19
4
+ data.tar.gz: 240d6c742cb7b907213ee6ad90cd5017d9dde8f256b61ef3d3d3cfc76a494c3b
5
5
  SHA512:
6
- metadata.gz: 8ff4552592d4f2786b00bd3ef1d5f7b75772bce584332e34387a47b6b10ffb4075b74ea1da2a8df3f0dc017edbdc8efc1d5ec580b0f7f5611a3a57a6223cd0fa
7
- data.tar.gz: bc45ffcc87acafbf00177d91dc4a4aa2bde9fd5c9ee1cdd99c29a7f0b51370ac28538283b5097214c83ec3dc31725a1cb210135939e04e85a216d67441da68b5
6
+ metadata.gz: 69226f609647ec2bc52c285102a9ef08789fdfdad9835e0d2df2ff00f0a02c20d39c824c8adcf956e172be266cb931d3158cd09e2271a88cd6f0c759220e9002
7
+ data.tar.gz: 66992848f981c89dbb2f3912dcd0cf2a1a1135186185bccbda194d2a82864a56b277313dd85edb37f9b55e4da22f44bd10b58e41b1fc858385d303b91622b371
data/README.md CHANGED
@@ -41,6 +41,11 @@ other|%d artists
41
41
  #### String Array: (Android)
42
42
  ["Monday", "Tuesday", "Wednesday"]
43
43
 
44
+ ## iOS specifics
45
+
46
+ In order to support Objective-C, the plugin provides the `support_objc` argument, which is default `false`.
47
+ Therefore, if you need Objective-C support pass `support_objc: true`.
48
+
44
49
  ## Example
45
50
 
46
51
  ```ruby
@@ -20,6 +20,8 @@ module Fastlane
20
20
  code_generation_path = params[:code_generation_path]
21
21
  identifier_name = params[:identifier_name]
22
22
  comment_example_language = params[:comment_example_language]
23
+ support_objc = params[:support_objc]
24
+ support_spm = params[:support_spm]
23
25
 
24
26
  if identifier_name.to_s.empty?
25
27
  if platform == "ios"
@@ -85,7 +87,7 @@ module Fastlane
85
87
  end
86
88
  end
87
89
  }
88
- self.createFiles(result, platform, path, default_language, base_language, code_generation_path, comment_example_language)
90
+ self.createFiles(result, platform, path, default_language, base_language, code_generation_path, comment_example_language, support_objc, support_spm)
89
91
  end
90
92
 
91
93
  def self.generateJSONObject(contentRows, index, identifierIndex)
@@ -131,7 +133,7 @@ module Fastlane
131
133
  }
132
134
  end
133
135
 
134
- def self.createFiles(languages, platform, destinationPath, defaultLanguage, base_language, codeGenerationPath, comment_example_language)
136
+ def self.createFiles(languages, platform, destinationPath, defaultLanguage, base_language, codeGenerationPath, comment_example_language, support_objc, support_spm)
135
137
  self.createFilesForLanguages(languages, platform, destinationPath, defaultLanguage, base_language)
136
138
 
137
139
  if platform == "web"
@@ -187,7 +189,7 @@ module Fastlane
187
189
  swiftFilepath = "#{swiftPath}/#{swiftFilename}"
188
190
 
189
191
  File.open(swiftFilepath, "w") do |f|
190
- f.write("import Foundation\n\n// swiftlint:disable all\npublic struct Localization {\n")
192
+ f.write("import Foundation\n\n// swiftlint:disable all\n#{getiOSTypeDefinition(support_objc)} {\n")
191
193
  filteredItems.each { |item|
192
194
 
193
195
  identifier = item['identifier']
@@ -220,14 +222,14 @@ module Fastlane
220
222
 
221
223
  if arguments.count == 0
222
224
  f.write(self.createComment(item['comment'], item['text']))
223
- f.write("public static let #{constantName} = localized(identifier: \"#{identifier}\")\n")
225
+ f.write("#{getiOSAttributes(support_objc)}public static let #{constantName} = localized(identifier: \"#{identifier}\")\n")
224
226
  else
225
227
  f.write(self.createComment(item['comment'], item['text']))
226
- f.write(self.createiOSFunction(constantName, identifier, arguments))
228
+ f.write(self.createiOSFunction(constantName, identifier, arguments, support_objc))
227
229
  end
228
230
  }
229
231
  f.write("\n}")
230
- f.write(self.createiOSFileEndString(destinationPath))
232
+ f.write(self.createiOSFileEndString(destinationPath, support_spm))
231
233
  end
232
234
 
233
235
  end
@@ -452,9 +454,9 @@ module Fastlane
452
454
  }
453
455
  end
454
456
 
455
- def self.createiOSFileEndString(destinationPath)
457
+ def self.createiOSFileEndString(destinationPath, support_spm)
456
458
 
457
- bundle = "let bundle = Bundle(for: LocalizationHelper.self)"
459
+ bundle = support_spm ? "let bundle = Bundle.module" : "let bundle = Bundle(for: LocalizationHelper.self)"
458
460
 
459
461
  puts destinationPath
460
462
 
@@ -476,8 +478,8 @@ module Fastlane
476
478
  \n})
477
479
  end
478
480
 
479
- def self.createiOSFunction(constantName, identifier, arguments)
480
- functionTitle = "public static func #{constantName}("
481
+ def self.createiOSFunction(constantName, identifier, arguments, support_objc)
482
+ functionTitle = "#{getiOSAttributes(support_objc)}public static func #{constantName}("
481
483
 
482
484
  arguments.each_with_index do |item, index|
483
485
  functionTitle = functionTitle + "_ arg#{index}: #{item[:type]}"
@@ -500,6 +502,14 @@ module Fastlane
500
502
  return functionTitle
501
503
  end
502
504
 
505
+ def self.getiOSTypeDefinition(support_objc)
506
+ return support_objc ? "public class Localization: NSObject" : "public struct Localization"
507
+ end
508
+
509
+ def self.getiOSAttributes(support_objc)
510
+ return support_objc ? "@objc " : ""
511
+ end
512
+
503
513
  def self.findArgumentsInText(text)
504
514
 
505
515
  if text.include?("one|")
@@ -509,30 +519,40 @@ module Fastlane
509
519
  result = Array.new
510
520
  filtered = self.mapInvalidPlaceholder(text)
511
521
 
512
- stringIndexes = filtered.scan(/%[0-9]?[s@]/)
513
- intIndexes = filtered.scan(/%[0-9]?[d]/)
514
- floatIndexes = filtered.scan(/%[0-9]?[f]/)
515
- doubleIndexes = filtered.scan(/%[0-9]?ld/)
522
+ stringIndexes = self.scan_str(filtered, /%[0-9]?[s@]/)
523
+ intIndexes = self.scan_str(filtered, /%[0-9]?[d]/)
524
+ floatIndexes = self.scan_str(filtered, /%[0-9]?[.f]/)
525
+ doubleIndexes = self.scan_str(filtered, /%[0-9]?ld/)
516
526
 
517
527
  if stringIndexes.count > 0
518
- result = result.concat(stringIndexes.map { |e| { "index": e, "type": "String" }})
528
+ result = result + stringIndexes.map { |e| { "index": e[0], "offset": e[1], "type": "String" }}
519
529
  end
520
530
 
521
531
  if intIndexes.count > 0
522
- result = result.concat(intIndexes.map { |e| { "index": e, "type": "Int" }})
532
+ result = result + intIndexes.map { |e| { "index": e[0], "offset": e[1], "type": "Int" }}
523
533
  end
524
534
 
525
535
  if floatIndexes.count > 0
526
- result = result.concat(floatIndexes.map { |e| { "index": e, "type": "Float" }})
536
+ result = result + floatIndexes.map { |e| { "index": e[0], "offset": e[1], "type": "Float" }}
527
537
  end
528
538
 
529
539
  if doubleIndexes.count > 0
530
- result = result.concat(doubleIndexes.map { |e| { "index": e, "type": "Double" }})
540
+ result = result + doubleIndexes.map { |e| { "index": e[0], "offset": e[1], "type": "Double" }}
531
541
  end
532
542
 
543
+ result = result.sort_by { |hsh| hsh[:offset] }
544
+
533
545
  return result
534
546
  end
535
547
 
548
+ def self.scan_str(str, pattern)
549
+ res = []
550
+ (0..str.length).each do |i|
551
+ res << [Regexp.last_match.to_s, i] if str[i..-1] =~ /^#{pattern}/
552
+ end
553
+ res
554
+ end
555
+
536
556
  def self.mapInvalidPlaceholder(text)
537
557
  filtered = text.gsub('%s', '%@').gsub('"', '\"')
538
558
  return filtered
@@ -580,6 +600,11 @@ module Fastlane
580
600
  default_value: [],
581
601
  optional: true,
582
602
  type: Array),
603
+ FastlaneCore::ConfigItem.new(key: :support_spm,
604
+ env_name: "SUPPORT_SPM",
605
+ description: "Is Swift Package",
606
+ default_value: false,
607
+ type: Boolean),
583
608
  FastlaneCore::ConfigItem.new(key: :language_titles,
584
609
  env_name: "LANGUAGE_TITLES",
585
610
  description: "Alle language titles",
@@ -614,7 +639,12 @@ module Fastlane
614
639
  env_name: "CODEGENERATIONPATH",
615
640
  description: "Code generation path for the Swift file",
616
641
  optional: true,
617
- type: String)
642
+ type: String),
643
+ FastlaneCore::ConfigItem.new(key: :support_objc,
644
+ env_name: "OBJC_SUPPORT",
645
+ description: "Whether the generated code should support Obj-C. Only relevant for the ios platform",
646
+ type: Boolean,
647
+ default_value: false)
618
648
  ]
619
649
  end
620
650
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GoogleSheetLocalize
3
- VERSION = "0.3.05"
3
+ VERSION = "0.3.13"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-google_sheet_localize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.05
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Hahn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-07 00:00:00.000000000 Z
11
+ date: 2021-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google_drive
@@ -181,8 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  requirements: []
184
- rubyforge_project:
185
- rubygems_version: 2.7.7
184
+ rubygems_version: 3.0.3
186
185
  signing_key:
187
186
  specification_version: 4
188
187
  summary: Creates .strings files for iOS and strings.xml files for Android