Skip to content

Commit c72d0ed

Browse files
authored
Fix metadata length computation logic (#383)
2 parents d527f50 + 84aacbd commit c72d0ed

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _None_
1414

1515
### Bug Fixes
1616

17-
_None_
17+
- Fix metadata length computation logic [[#383](https://github.com/wordpress-mobile/release-toolkit/pull/383)]
1818

1919
### Internal Changes
2020

@@ -55,7 +55,7 @@ _None_
5555

5656
### New Features
5757

58-
* Add the option for `an_localize_libs` to provide a `source_id` for each library being merged.
58+
* Add the option for `an_localize_libs` to provide a `source_id` for each library being merged.
5959
If provided, that identifier will be added as an `a8c-src-lib` XML attribute to the `<string>` nodes being updated with strings from said library.
6060
This can be useful to help identify where each string come from in the resulting, merged `strings.xml`. [#351]
6161
* Add the option for `an_localize_libs` to set the `tools:ignore="UnusedResources"` XML attribute for each string being merged from a library. [#354]

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)