fastlane-plugin-google_sheet_localize 0.1.54 → 0.1.61

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: ca0a7c8b39bcba4562285f0e04b78d18985d058b02fa3190906827ca08a05034
4
- data.tar.gz: f542192380763fd64fdc22f4a7ec5e6f72e62aa396789814db2025824ab84cb6
3
+ metadata.gz: 53568c7a605fe89cbadbe04ce64d0f1cf1bd48d3324fadbdbcb017ca97c7e68d
4
+ data.tar.gz: 69a1415e7f0c7582ab390d0aef9690f93194a48cf877c50fa77a330cbbbf61c2
5
5
  SHA512:
6
- metadata.gz: 414d513e932c344facd9321d59985ad186d101ced91709294694be4a5189b1c660493b04d3be7a81172c247bad8652705201d6ccc2dd60c3284506bdbf703721
7
- data.tar.gz: fe0f35acc913ef7f3e3adb4848173d689a855cf51238d240ca45ec8ce52a902ce6ec832db448ee0d8f364bca8f5d537fba143611f80a20a729536e7709947040
6
+ metadata.gz: 039de61d11dd9fa3d0d27b65ee02b3044620a2981f493f47640d8392685061e3d4aa335cf3a1690bdb94f54e27f1e11c3b34dac2d9109f98f2f2bb9879951720
7
+ data.tar.gz: a05659f1896c2861f2a7c3ab21017b04427007462f3e647c24f023be947dca1e52443545bca15dc229464a24350162634d4e4bee3ec53117ea0693b706901c58
@@ -14,6 +14,7 @@ module Fastlane
14
14
  platform = params[:platform]
15
15
  path = params[:localization_path]
16
16
  language_titles = params[:language_titles]
17
+ default_language = params[:default_language]
17
18
 
18
19
  spreadsheet = session.spreadsheet_by_url(spreadsheet_id)
19
20
  worksheet = spreadsheet.worksheets.first
@@ -47,7 +48,7 @@ module Fastlane
47
48
  result.push(language)
48
49
  end
49
50
  end
50
- self.createFiles(result, platform, path)
51
+ self.createFiles(result, platform, path, default_language)
51
52
  end
52
53
 
53
54
  def self.generateJSONObject(contentRows, index)
@@ -64,12 +65,6 @@ module Fastlane
64
65
 
65
66
  end
66
67
 
67
- def self.writeToJSONFile(languages)
68
- File.open("output.json","w") do |f|
69
- f.write(JSON.pretty_generate(languages))
70
- end
71
- end
72
-
73
68
  def self.generateSingleObject(row, column)
74
69
  identifierIos = row[0]
75
70
  identifierAndroid = row[1]
@@ -87,8 +82,15 @@ module Fastlane
87
82
 
88
83
  end
89
84
 
90
- def self.createFiles(languages, platform, destinationPath)
91
- languages.each { |language| self.createFileForLanguage(language, platform, destinationPath) }
85
+ def filterUnusedRows(items, identifier)
86
+ return items.select { |item|
87
+ iosIdentifier = item[identifier]
88
+ iosIdentifier != "NR" && iosIdentifier != ""
89
+ }
90
+ end
91
+
92
+ def self.createFiles(languages, platform, destinationPath, defaultLanguage)
93
+ self.createFilesForLanguages(languages, platform, destinationPath, defaultLanguage)
92
94
 
93
95
  if platform == "ios"
94
96
 
@@ -135,29 +137,38 @@ module Fastlane
135
137
  end
136
138
  end
137
139
 
138
- def self.createFileForLanguage(language, platform, destinationPath)
140
+ def self.createFilesForLanguages(languages, platform, destinationPath, defaultLanguage)
141
+
142
+ languages.each { |language|
143
+
139
144
  if platform == "ios"
140
145
 
141
- filteredItems = language["items"].select { |item|
142
- iosIdentifier = item['identifierIos']
143
- iosIdentifier != "NR" && iosIdentifier != ""
144
- }
146
+ filteredItems = self.filterUnusedRows(language["items"],'identifierIos')
145
147
 
146
148
  filename = "Localizable.strings"
147
149
  filepath = "#{destinationPath}/#{language['language']}.lproj/#{filename}"
148
150
  FileUtils.mkdir_p "#{destinationPath}/#{language['language']}.lproj"
149
151
  File.open(filepath, "w") do |f|
150
- filteredItems.each { |item|
152
+ filteredItems.each_with_index { |item, index|
151
153
 
152
154
  text = self.mapInvalidPlaceholder(item['text'])
153
155
  comment = item['comment']
154
156
  identifier = item['identifierIos']
155
157
 
156
158
  line = ""
157
-
158
159
  if identifier.include?('//')
159
160
  line = "\n\n#{identifier}\n"
160
161
  else
162
+
163
+ if text == "" || text == "TBD"
164
+ default_language_object = languages.select { |languageItem| languageItem['language'] == defaultLanguage }.first["items"]
165
+ default_language_object = self.filterUnusedRows(default_language_object,'identifierIos')
166
+
167
+ defaultLanguageText = default_language_object[index]['text']
168
+ puts "found empty text for identifier: #{identifier} for language:#{language['language']}, replaceing it with #{defaultLanguageText}"
169
+ text = self.mapInvalidPlaceholder(defaultLanguageText)
170
+ end
171
+
161
172
  line = "\"#{identifier}\" = \"#{text}\";"
162
173
  if !comment.to_s.empty?
163
174
  line = line + " //#{comment}\n"
@@ -205,6 +216,7 @@ module Fastlane
205
216
  f.write("</resources>\n")
206
217
  end
207
218
  end
219
+ }
208
220
  end
209
221
 
210
222
  def self.createiOSFileEndString()
@@ -314,6 +326,11 @@ module Fastlane
314
326
  description: "Alle language titles",
315
327
  optional: false,
316
328
  type: Array),
329
+ FastlaneCore::ConfigItem.new(key: :default_language,
330
+ env_name: "DEFAULT_LANGUAGE",
331
+ description: "Default Language",
332
+ optional: false,
333
+ type: String),
317
334
  FastlaneCore::ConfigItem.new(key: :localization_path,
318
335
  env_name: "LOCALIZATION_PATH",
319
336
  description: "Output path",
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GoogleSheetLocalize
3
- VERSION = "0.1.54"
3
+ VERSION = "0.1.61"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-google_sheet_localize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.54
4
+ version: 0.1.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Hahn