-
Notifications
You must be signed in to change notification settings - Fork 3
[Tooling] Add GlotPress integration for Fluent localization files #756
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
Conversation
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 13.2', git: 'https://github.com/wordpress-mobile/release-toolkit.git', | ||
branch: 'iangmaia/fluent-po-conversion-actions' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎗️ Just adding a comment here to serve as a reminder to not merge this PR until we'll have a new version of the release-toolkit
shipped and this Gemfile
updated to point to it.
fastlane/Fastfile
Outdated
# Ensure PO output directory exists | ||
FileUtils.mkdir_p(download_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to use Dir.mktmpdir do |download_dir| … end
instead, not only because this is more idiomatic Ruby when we need a temp dir, but also to guarantee that the temp folder being cleared and deleted once the job is done, and thus that any subsequent runs won't accidentally use a previously downloaded file left over from a previous run.
fastlane/Fastfile
Outdated
# Download PO file using curl | ||
sh("curl -s -o '#{po_file_path}' '#{download_url}'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is far from idiomatic Ruby, requires shelling out, and is not secure (especially it's vulnerable to command injections).
There are better methods in Ruby to download files from an URI. For example, something like this should work I think:
require 'open-uri'
File.write(po_file_path, URI.open(download_url).read)
Moved PR back to Draft after a few discussions with @AliSoftware about the actions generating / parsing the intermediate files and possible alternatives. |
2381d75
to
e55d460
Compare
This PR is superseded by #765 |
Related:
What does it do?
This PR integrates the new Fluent-to-PO conversion actions from release-toolkit to enable a complete translation workflow between the project's Fluent localization files (.ftl) and GlotPress, allowing for:
Key new lanes
generate_source_po_file
lane - Convertsen-US/main.ftl
toen-US.pot
for GlotPress uploaddownload_translations
lane - Downloads all available translations from GlotPress following the supported locales list and updates local Fluent filesgenerate_fluent_file_from_po
lane - Converts individual PO files back to Fluent formatdownload_po_files_from_glotpress
lane - Downloads PO files for all supported localesLocalization workflow
A day-to-day workflow, to be automated in the next PRs, could work like this (suggestions are welcome):
wp_localization/localization/en-US/main.ftl
.trunk
? A daily scheduled build?), we rungenerate_source_po_file
and commit the updatedwp_localization/glotpress/en-US.pot
.wpcom
job uploads the updateden-US
source file to GlotPress (see 184627-ghe-Automattic/wpcom )download_translations
.