fastlane-plugin-google_sheet_localize 0.1.83 → 0.1.90

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: 3bcddf273efd4e581c51675e403d9e6deb10f69af4f8ba82a2039fbbba98dfaf
4
- data.tar.gz: c1631bb5d16251bc3029596e23da641623940abab8e11b35a68f084e05453a2a
3
+ metadata.gz: c477b09125bf963ad1cba7d7baf0a47ddd3f142945e7b13661f66a35eb10fc56
4
+ data.tar.gz: 0debc49b63334226bbdeb5b66c218e94f36e5ae4035c56ff6fde94044d20d0f3
5
5
  SHA512:
6
- metadata.gz: 6976550256e396f5b846b5278f6dfb95691f8f07bf4a07513dcf3284bcaa24f8802fcf604422b0a9847827e9e5b5043da047491f66bc7f03123292d18a943fb0
7
- data.tar.gz: c10a4de3ba7f8a6e6b0e682afa38c44e39c86470c6442931fb5af8c9acabedf66eda214cd20837f6d4af0f7308db71ec7d75c47a628e6ee4b599c21f6d912e44
6
+ metadata.gz: f197744c24c25e4774f6d7be02b74fe358809952bf82b7613aa08bce1b759c7a1508f701ce7074401e6e446027708ac72917962bcd14e3035cffabfbe7ca0c6d
7
+ data.tar.gz: 97b2dedf9ba84b33735adcf5f30bb243acbdca2bddd5fdc262f4010d27ffd1ab5b2198f3d3ab1e34bf31fe5e00c2ad67ddeb53af7867435a9252df5d6e1cfcc6
@@ -156,7 +156,8 @@ module Fastlane
156
156
 
157
157
  filteredItems = self.filterUnusedRows(language["items"],'identifierIos')
158
158
 
159
- filename = "Localizable.strings"
159
+ stringFileName = "Localizable.strings"
160
+ pluralsFileName = "Plurals.stringsdict"
160
161
 
161
162
  languageName = language['language']
162
163
 
@@ -164,9 +165,11 @@ module Fastlane
164
165
  languageName = "Base"
165
166
  end
166
167
 
167
- filepath = "#{destinationPath}/#{languageName}.lproj/#{filename}"
168
+ stringFilepath = "#{destinationPath}/#{languageName}.lproj/#{filename}"
169
+ pluralsFilepath = "#{destinationPath}/#{languageName}.lproj/#{pluralsFileName}"
168
170
  FileUtils.mkdir_p "#{destinationPath}/#{languageName}.lproj"
169
- File.open(filepath, "w") do |f|
171
+
172
+ File.open(stringFilepath, "w") do |f|
170
173
  filteredItems.each_with_index { |item, index|
171
174
 
172
175
  text = self.mapInvalidPlaceholder(item['text'])
@@ -178,6 +181,44 @@ module Fastlane
178
181
  line = "\n\n#{identifier}\n"
179
182
  else
180
183
 
184
+ if !text.include?("one|")
185
+
186
+ if text == "" || text == "TBD"
187
+ default_language_object = languages.select { |languageItem| languageItem['language'] == defaultLanguage }.first["items"]
188
+ default_language_object = self.filterUnusedRows(default_language_object,'identifierIos')
189
+
190
+ defaultLanguageText = default_language_object[index]['text']
191
+ puts "found empty text for:\n\tidentifier: #{identifier}\n\tlanguage:#{language['language']}\n\treplacing it with: #{defaultLanguageText}"
192
+ text = self.mapInvalidPlaceholder(defaultLanguageText)
193
+ end
194
+
195
+ line = "\"#{identifier}\" = \"#{text}\";"
196
+ if !comment.to_s.empty?
197
+ line = line + " //#{comment}\n"
198
+ else
199
+ line = line + "\n"
200
+ end
201
+ end
202
+ end
203
+ f.write(line)
204
+ }
205
+ end
206
+
207
+ File.open(pluralsFilepath, "w") do |f|
208
+
209
+ f.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<plist version=\"1.0\">\n<dict>")
210
+ f.write("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n")
211
+ f.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
212
+ f.write("<plist version=\"1.0\">\n")
213
+ f.write("<dict>\n")
214
+
215
+ filteredItems.each_with_index { |item, index|
216
+
217
+ text = self.mapInvalidPlaceholder(item['text'])
218
+ identifier = item['identifierIos']
219
+
220
+ line = ""
221
+ if !identifier.include?('//') && text.include?("one|")
181
222
  if text == "" || text == "TBD"
182
223
  default_language_object = languages.select { |languageItem| languageItem['language'] == defaultLanguage }.first["items"]
183
224
  default_language_object = self.filterUnusedRows(default_language_object,'identifierIos')
@@ -187,16 +228,32 @@ module Fastlane
187
228
  text = self.mapInvalidPlaceholder(defaultLanguageText)
188
229
  end
189
230
 
190
- line = "\"#{identifier}\" = \"#{text}\";"
191
- if !comment.to_s.empty?
192
- line = line + " //#{comment}\n"
193
- else
194
- line = line + "\n"
195
- end
231
+ text = text.gsub("\n", "|")
232
+
233
+ f.write("\t\t<key>#{identifier}</key>\n")
234
+ f.write("\t\t<dict>\n")
235
+ f.write("\t\t\t<key>NSStringLocalizedFormatKey</key>\n")
236
+ f.write("\t\t\t<string>%#@#{identifier}@</string>\n")
237
+ f.write("\t\t\t<key>#{identifier}</key>\n")
238
+ f.write("\t\t\t<dict>\n")
239
+ f.write("\t\t\t\t<key>NSStringFormatSpecTypeKey</key>\n")
240
+ f.write("\t\t\t\t<string>NSStringPluralRuleType</string>\n")
241
+ f.write("\t\t\t\t<key>NSStringFormatValueTypeKey</key>\n")
242
+ f.write("\t\t\t\t<string>d</string>\n")
243
+
244
+ text.split("|").each_with_index { |word, wordIndex|
245
+ if wordIndex % 2 == 0
246
+ f.write("\t\t\t\t<key>#{word}</key>\n")
247
+ else
248
+ f.write("\t\t\t\t<string>#{word}</string>\n")
249
+ end
250
+ }
251
+ f.write("\t\t\t</dict>\n")
252
+ f.write("\t\t</dict>\n")
196
253
  end
197
-
198
- f.write(line)
199
254
  }
255
+ f.write("</dict>\n")
256
+ f.write("</plist>\n")
200
257
  end
201
258
  end
202
259
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GoogleSheetLocalize
3
- VERSION = "0.1.83"
3
+ VERSION = "0.1.90"
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.83
4
+ version: 0.1.90
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Hahn