Skip to content

Commit 8dea555

Browse files
committed
Fix metadata length computation logic
1 parent 801fecf commit 8dea555

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def parse_data(target_locale, loc_data, is_source)
4040
target_files.each do |file|
4141
if file[0].to_s == key
4242
data = file[1]
43-
msg = is_source ? source : d[1]
43+
msg = is_source ? source : d[1].first || '' # In the JSON, each Hash value is an array, with zero or one entry
4444
update_key(target_locale, key, file, data, msg)
4545
end
4646
end
@@ -58,15 +58,15 @@ def reparse_alternates(target_locale, loc_data, is_source)
5858
if file[0].to_s == key
5959
puts "Alternate: #{key}"
6060
data = file[1]
61-
msg = is_source ? source : d[1]
61+
msg = is_source ? source : d[1].first || '' # In the JSON, each Hash value is an array, with zero or one entry
6262
update_key(target_locale, key, file, data, msg)
6363
end
6464
end
6565
end
6666
end
6767

6868
def update_key(target_locale, key, file, data, msg)
69-
message_len = msg.to_s.length - 4 # Don't count JSON delimiters.
69+
message_len = msg.length
7070
if (data.key?(:max_size)) && (data[:max_size] != 0) && ((message_len) > data[:max_size])
7171
if data.key?(:alternate_key)
7272
UI.message("#{target_locale} translation for #{key} exceeds maximum length (#{message_len}). Switching to the alternate translation.")

0 commit comments

Comments
 (0)