Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exact file format specs for text files synced from Google Play? #14251

Closed
3 tasks done
eighthave opened this issue Feb 15, 2019 · 3 comments
Closed
3 tasks done

Exact file format specs for text files synced from Google Play? #14251

eighthave opened this issue Feb 15, 2019 · 3 comments

Comments

@eighthave
Copy link

eighthave commented Feb 15, 2019

Question Checklist

Question Subject

Weblate has implemented support for the native Fastlane text files so the can be easily translated. Weblate is based on git repos, so whitespace changes can cause merge conflicts and unnecessary noise. So it is important to minimize whitespace changes as much as possible for a smooth, automated workflow. Towards that end, we'd like to know more about how Fastlane handles the text files so that Weblate does the same thing. Is there a canonical format for title.txt, summary.txt, etc. regarding leading and trailing spaces? Does fastlane write out title.txt, summary.txt, etc. based on the data from Google Play without modifying it? Does anyone know if submitting to Google Play, then fetching from Google Play will strip whitespace?

For more info:
WeblateOrg/weblate#1525 (comment)
@janpio @nijel

@janpio
Copy link
Member

janpio commented Feb 15, 2019

Data is downloaded here:

v = options[:app].latest_version
metadata_path = options[:metadata_path] || File.join(deliver_path, 'metadata')
generate_metadata_files(v, metadata_path)

And then written to files here:
def generate_metadata_files(v, path)
app_details = v.application.details
# All the localised metadata
(UploadMetadata::LOCALISED_VERSION_VALUES + UploadMetadata::LOCALISED_APP_VALUES).each do |key|
v.description.languages.each do |language|
if UploadMetadata::LOCALISED_VERSION_VALUES.include?(key)
content = v.send(key)[language].to_s
else
content = app_details.send(key)[language].to_s
end
content << "\n"
resulting_path = File.join(path, language, "#{key}.txt")
FileUtils.mkdir_p(File.expand_path('..', resulting_path))
File.write(resulting_path, content)
UI.message("Writing to '#{resulting_path}'")
end
end
# All non-localised metadata
(UploadMetadata::NON_LOCALISED_VERSION_VALUES + UploadMetadata::NON_LOCALISED_APP_VALUES).each do |key|
if UploadMetadata::NON_LOCALISED_VERSION_VALUES.include?(key)
content = v.send(key).to_s
else
content = app_details.send(key).to_s
end
content << "\n"
resulting_path = File.join(path, "#{key}.txt")
File.write(resulting_path, content)
UI.message("Writing to '#{resulting_path}'")
end
# Trade Representative Contact Information
UploadMetadata::TRADE_REPRESENTATIVE_CONTACT_INFORMATION_VALUES.each do |key, option_name|
content = v.send(key).to_s
content << "\n"
base_dir = File.join(path, UploadMetadata::TRADE_REPRESENTATIVE_CONTACT_INFORMATION_DIR)
FileUtils.mkdir_p(base_dir)
resulting_path = File.join(base_dir, "#{option_name}.txt")
File.write(resulting_path, content)
UI.message("Writing to '#{resulting_path}'")
end
# Review information
UploadMetadata::REVIEW_INFORMATION_VALUES.each do |key, option_name|
content = v.send(key).to_s
content << "\n"
base_dir = File.join(path, UploadMetadata::REVIEW_INFORMATION_DIR)
FileUtils.mkdir_p(base_dir)
resulting_path = File.join(base_dir, "#{option_name}.txt")
File.write(resulting_path, content)
UI.message("Writing to '#{resulting_path}'")
end
UI.success("Successfully created new configuration files.")
# get App icon + watch icon
if v.large_app_icon.asset_token
app_icon_extension = File.extname(v.large_app_icon.url)
app_icon_path = File.join(path, "app_icon#{app_icon_extension}")
File.write(app_icon_path, open(v.large_app_icon.url).read)
UI.success("Successfully downloaded large app icon")
end
if v.watch_app_icon.asset_token
watch_app_icon_extension = File.extname(v.watch_app_icon.url)
watch_icon_path = File.join(path, "watch_icon#{watch_app_icon_extension}")
File.write(watch_icon_path, open(v.watch_app_icon.url).read)
UI.success("Successfully downloaded watch icon")
end
end

Lets focus on one specific example:

if UploadMetadata::LOCALISED_VERSION_VALUES.include?(key)
content = v.send(key)[language].to_s
else
content = app_details.send(key)[language].to_s
end
content << "\n"
resulting_path = File.join(path, language, "#{key}.txt")
FileUtils.mkdir_p(File.expand_path('..', resulting_path))
File.write(resulting_path, content)

First it gets the data. Then it adds a \n at the end, and writes the result to the file.

So my guess: The API returns a trimmed string, fastlane/deliver adds the last line break before writing to the file (Linux style).

You should be able to confirm by testing this with your own apps. Best also try to add a few empty lines at the description for example - my guess is that Google strips those when saving anyway so the API always returns trimmed values.

@janpio janpio changed the title exact file format specs for text files synced from Google Play Exact file format specs for text files synced from Google Play? Feb 15, 2019
@fastlane-bot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest fastlane version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

@fastlane-bot
Copy link

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

@fastlane fastlane locked and limited conversation to collaborators Jun 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants