fastlane-plugin-google_sheet_localize 0.3.04 → 0.3.12

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: e212c4364acd3ce209bcb89e3bf988c1dcc4b0fccd984a02b3c8daf2d1a3f4bd
4
- data.tar.gz: ef896141f5fd95cc775f511dc7904a5ba3d8f858c56431c281f213897ccd8cff
3
+ metadata.gz: 9fced4de18f8a5080a5434880e0cfaf1a913b94ce99fa0cf616d4c3aef17841e
4
+ data.tar.gz: a31f53557155e56132a9591069c9f145deeadcb43cb1c1de26c21b577c832dc0
5
5
  SHA512:
6
- metadata.gz: 0eb92e7d0ef452b6ad3f522b86cb5adafc6877e7b304059ad0e7826a6675056e4af4e4210b64245c591c8b21f51d8fb695401790d5b424b8a4dc6ea196f8d0d8
7
- data.tar.gz: 0ae0c1f89d48a4317c1c5bc84bba7ed21b90aae48d6c50a714fb01bd2020abc13f1bf01a611dbfc9d433422c77129d74721421e8a733205bf7f4d51280dd9bff
6
+ metadata.gz: 20e49808b8a3c5a3ea3570ce9d87d833ea4d152136e8c792d1571d1a61b227051d9d046e1db533ad1a3968fb09b292ab7cf05ea973e42edf848c556e26081e60
7
+ data.tar.gz: 403dc72598654501cd42e7acca89a98e7d6963513c03cbd5b5d79e542163b9cfff0df5aaa39e4ced4163656cc81508a45a4120ece9237746109e4b117602e876
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
@@ -288,7 +290,6 @@ module Fastlane
288
290
  line = "\n\n#{identifier}\n"
289
291
  else
290
292
 
291
- if !text.include?("one|")
292
293
 
293
294
  if (text == "" || text == "TBD") && !defaultLanguage.to_s.empty?
294
295
  default_language_object = languages.select { |languageItem| languageItem['language'] == defaultLanguage }.first["items"]
@@ -299,6 +300,8 @@ module Fastlane
299
300
  text = self.mapInvalidPlaceholder(defaultLanguageText)
300
301
  end
301
302
 
303
+ if !text.include?("one|")
304
+
302
305
  matches = text.scan(/%[0-9][sdf]/)
303
306
 
304
307
  matches.each { |match|
@@ -329,7 +332,6 @@ module Fastlane
329
332
  text = self.mapInvalidPlaceholder(item['text'])
330
333
  identifier = item['identifier']
331
334
 
332
- if !identifier.include?('//') && text.include?("one|")
333
335
  if (text == "" || text == "TBD") && !defaultLanguage.to_s.empty?
334
336
  default_language_object = languages.select { |languageItem| languageItem['language'] == defaultLanguage }.first["items"]
335
337
  default_language_object = self.filterUnusedRows(default_language_object,'identifier', "false")
@@ -339,6 +341,8 @@ module Fastlane
339
341
  text = self.mapInvalidPlaceholder(defaultLanguageText)
340
342
  end
341
343
 
344
+ if !identifier.include?('//') && text.include?("one|")
345
+
342
346
  text = text.gsub("\n", "|")
343
347
 
344
348
  formatIdentifier = identifier.gsub(".", "")
@@ -450,9 +454,9 @@ module Fastlane
450
454
  }
451
455
  end
452
456
 
453
- def self.createiOSFileEndString(destinationPath)
457
+ def self.createiOSFileEndString(destinationPath, support_spm)
454
458
 
455
- bundle = "let bundle = Bundle(for: LocalizationHelper.self)"
459
+ bundle = support_spm ? "let bundle = Bundle.module" : "let bundle = Bundle(for: LocalizationHelper.self)"
456
460
 
457
461
  puts destinationPath
458
462
 
@@ -474,8 +478,8 @@ module Fastlane
474
478
  \n})
475
479
  end
476
480
 
477
- def self.createiOSFunction(constantName, identifier, arguments)
478
- functionTitle = "public static func #{constantName}("
481
+ def self.createiOSFunction(constantName, identifier, arguments, support_objc)
482
+ functionTitle = "#{getiOSAttributes(support_objc)}public static func #{constantName}("
479
483
 
480
484
  arguments.each_with_index do |item, index|
481
485
  functionTitle = functionTitle + "_ arg#{index}: #{item[:type]}"
@@ -498,6 +502,14 @@ module Fastlane
498
502
  return functionTitle
499
503
  end
500
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
+
501
513
  def self.findArgumentsInText(text)
502
514
 
503
515
  if text.include?("one|")
@@ -507,30 +519,40 @@ module Fastlane
507
519
  result = Array.new
508
520
  filtered = self.mapInvalidPlaceholder(text)
509
521
 
510
- stringIndexes = filtered.scan(/%[0-9]?[s@]/)
511
- intIndexes = filtered.scan(/%[0-9]?[d]/)
512
- floatIndexes = filtered.scan(/%[0-9]?[f]/)
513
- 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/)
514
526
 
515
527
  if stringIndexes.count > 0
516
- result = result.concat(stringIndexes.map { |e| { "index": e, "type": "String" }})
528
+ result = result.concat(stringIndexes.map { |e| { "index": e[0], "offset": e[1], "type": "String" }})
517
529
  end
518
530
 
519
531
  if intIndexes.count > 0
520
- result = result.concat(intIndexes.map { |e| { "index": e, "type": "Int" }})
532
+ result = result.concat(intIndexes.map { |e| { "index": e[0], "offset": e[1], "type": "Int" }})
521
533
  end
522
534
 
523
535
  if floatIndexes.count > 0
524
- result = result.concat(floatIndexes.map { |e| { "index": e, "type": "Float" }})
536
+ result = result.concat(floatIndexes.map { |e| { "index": e[0], "offset": e[1], "type": "Float" }})
525
537
  end
526
538
 
527
539
  if doubleIndexes.count > 0
528
- result = result.concat(doubleIndexes.map { |e| { "index": e, "type": "Double" }})
540
+ result = result.concat(doubleIndexes.map { |e| { "index": e[0], "offset": e[1], "type": "Double" }})
529
541
  end
530
542
 
543
+ result = result.sort_by! { |k| k["offset"] }.reverse!
544
+
531
545
  return result
532
546
  end
533
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
+
534
556
  def self.mapInvalidPlaceholder(text)
535
557
  filtered = text.gsub('%s', '%@').gsub('"', '\"')
536
558
  return filtered
@@ -578,6 +600,11 @@ module Fastlane
578
600
  default_value: [],
579
601
  optional: true,
580
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),
581
608
  FastlaneCore::ConfigItem.new(key: :language_titles,
582
609
  env_name: "LANGUAGE_TITLES",
583
610
  description: "Alle language titles",
@@ -612,7 +639,12 @@ module Fastlane
612
639
  env_name: "CODEGENERATIONPATH",
613
640
  description: "Code generation path for the Swift file",
614
641
  optional: true,
615
- 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)
616
648
  ]
617
649
  end
618
650
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GoogleSheetLocalize
3
- VERSION = "0.3.04"
3
+ VERSION = "0.3.12"
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.04
4
+ version: 0.3.12
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-06-13 00:00:00.000000000 Z
11
+ date: 2021-03-22 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