Skip to content

Commit

Permalink
Add explanatory comment to upload_files
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisandreae authored Oct 1, 2024
1 parent 29e0bc9 commit 4c4b036
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/phraseapp_updater/phraseapp_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@ def download_files(locales, skip_unverified:)
end
end

# Empirically, PhraseApp fails to parse the uploaded files when uploaded in
# parallel. Give it a better chance by uploading them one at a time.
def upload_files(locale_files, default_locale:)
locale_files = locale_files.sort_by(&:locale_name)
default_locale_file = locale_files.detect { |l| l.locale_name == default_locale }
locale_files.delete(default_locale_file) if default_locale_file

known_locales = fetch_locales.index_by(&:name)

# Phraseapp appears to use to use the first file uploaded to resolve conflicts
# between pluralized and non-pluralized keys. Upload and verify the canonical
# default locale first before uploading translated locales.
if default_locale_file
unless known_locales.has_key?(default_locale_file.locale_name)
STDERR.puts("Creating default locale (#{default_locale_file})")
Expand Down

0 comments on commit 4c4b036

Please sign in to comment.