fastlane-plugin-google_sheet_localize 0.3.03 → 0.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0e9d2ad57caefd5801f7a24cb4152e61b76309bfc7a1a2b2854c09b5adf6b21
4
- data.tar.gz: a7fd0f0f98838de2ba7a657aad4f9a5e87b89b65df040690c3ca37dd9d7a9dbe
3
+ metadata.gz: 9b5d87c095c7e5ca644cad2b1843e389dc0772a30f10ee213fb21e8d5bb64e14
4
+ data.tar.gz: d85062c292448a24ca74fce441cb57369a588d30a3581f4929281bf605acbb3f
5
5
  SHA512:
6
- metadata.gz: 2675ff5f470ee39d74861b6445d9df5ef4176a622269b1196fe33bf936ee586511f63cf45d66b654059718fa4e25fb70f2fe4662634aadb5fd733fdec7992fba
7
- data.tar.gz: f237f54b45bc8ea3030f016d88322fd4da030202b17bc3593207432546712140580d078d0a3d559c8307415d8b388fb66dc7d65eae59e550e75fcb1a8b17dbe1
6
+ metadata.gz: 129d2376d444e9b473a455085a7b1fd58ced4a95820f4a8dd339a3c8e0021e44f505bee4c6cbdfd522200a6033017653230cfd78dded79259a09375d4141221e
7
+ data.tar.gz: 1130f9c3f659b4b0ad46c7d09745fb002cce7d16b3de2fc78c32e14121d84f57d733e4b8ee2c62e999a5d077149bd57d73a9e2f8342d41378ff5500548e9ca0f
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,12 +189,12 @@ 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']
194
196
 
195
- values = identifier.dup.split(".")
197
+ values = identifier.dup.split(/\.|_/)
196
198
 
197
199
  constantName = ""
198
200
 
@@ -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
@@ -238,24 +240,19 @@ module Fastlane
238
240
  if comment.to_s.empty?
239
241
  return %Q(
240
242
  /**
241
- - Example:
242
- ````
243
243
  #{example}
244
- ````
245
244
  */
246
245
  )
247
246
  end
248
247
 
249
248
  return %Q(
250
249
  /**
250
+ #{example}
251
+
251
252
  - Sheet comment:
252
253
  ````
253
254
  #{comment}
254
255
  ````
255
- - Example:
256
- ````
257
- #{example}
258
- ````
259
256
  */
260
257
  )
261
258
  end
@@ -293,7 +290,6 @@ module Fastlane
293
290
  line = "\n\n#{identifier}\n"
294
291
  else
295
292
 
296
- if !text.include?("one|")
297
293
 
298
294
  if (text == "" || text == "TBD") && !defaultLanguage.to_s.empty?
299
295
  default_language_object = languages.select { |languageItem| languageItem['language'] == defaultLanguage }.first["items"]
@@ -304,6 +300,8 @@ module Fastlane
304
300
  text = self.mapInvalidPlaceholder(defaultLanguageText)
305
301
  end
306
302
 
303
+ if !text.include?("one|")
304
+
307
305
  matches = text.scan(/%[0-9][sdf]/)
308
306
 
309
307
  matches.each { |match|
@@ -334,7 +332,6 @@ module Fastlane
334
332
  text = self.mapInvalidPlaceholder(item['text'])
335
333
  identifier = item['identifier']
336
334
 
337
- if !identifier.include?('//') && text.include?("one|")
338
335
  if (text == "" || text == "TBD") && !defaultLanguage.to_s.empty?
339
336
  default_language_object = languages.select { |languageItem| languageItem['language'] == defaultLanguage }.first["items"]
340
337
  default_language_object = self.filterUnusedRows(default_language_object,'identifier', "false")
@@ -344,6 +341,8 @@ module Fastlane
344
341
  text = self.mapInvalidPlaceholder(defaultLanguageText)
345
342
  end
346
343
 
344
+ if !identifier.include?('//') && text.include?("one|")
345
+
347
346
  text = text.gsub("\n", "|")
348
347
 
349
348
  formatIdentifier = identifier.gsub(".", "")
@@ -455,9 +454,9 @@ module Fastlane
455
454
  }
456
455
  end
457
456
 
458
- def self.createiOSFileEndString(destinationPath)
457
+ def self.createiOSFileEndString(destinationPath, support_spm)
459
458
 
460
- bundle = "let bundle = Bundle(for: LocalizationHelper.self)"
459
+ bundle = support_spm ? "let bundle = Bundle.module" : "let bundle = Bundle(for: LocalizationHelper.self)"
461
460
 
462
461
  puts destinationPath
463
462
 
@@ -479,8 +478,8 @@ module Fastlane
479
478
  \n})
480
479
  end
481
480
 
482
- def self.createiOSFunction(constantName, identifier, arguments)
483
- functionTitle = "public static func #{constantName}("
481
+ def self.createiOSFunction(constantName, identifier, arguments, support_objc)
482
+ functionTitle = "#{getiOSAttributes(support_objc)}public static func #{constantName}("
484
483
 
485
484
  arguments.each_with_index do |item, index|
486
485
  functionTitle = functionTitle + "_ arg#{index}: #{item[:type]}"
@@ -503,6 +502,14 @@ module Fastlane
503
502
  return functionTitle
504
503
  end
505
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
+
506
513
  def self.findArgumentsInText(text)
507
514
 
508
515
  if text.include?("one|")
@@ -583,6 +590,11 @@ module Fastlane
583
590
  default_value: [],
584
591
  optional: true,
585
592
  type: Array),
593
+ FastlaneCore::ConfigItem.new(key: :support_spm,
594
+ env_name: "SUPPORT_SPM",
595
+ description: "Is Swift Package",
596
+ default_value: false,
597
+ type: Boolean),
586
598
  FastlaneCore::ConfigItem.new(key: :language_titles,
587
599
  env_name: "LANGUAGE_TITLES",
588
600
  description: "Alle language titles",
@@ -617,7 +629,12 @@ module Fastlane
617
629
  env_name: "CODEGENERATIONPATH",
618
630
  description: "Code generation path for the Swift file",
619
631
  optional: true,
620
- type: String)
632
+ type: String),
633
+ FastlaneCore::ConfigItem.new(key: :support_objc,
634
+ env_name: "OBJC_SUPPORT",
635
+ description: "Whether the generated code should support Obj-C. Only relevant for the ios platform",
636
+ type: Boolean,
637
+ default_value: false)
621
638
  ]
622
639
  end
623
640
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GoogleSheetLocalize
3
- VERSION = "0.3.03"
3
+ VERSION = "0.3.11"
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.03
4
+ version: 0.3.11
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-04-17 00:00:00.000000000 Z
11
+ date: 2021-02-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