|
11 | 11 | # First are the locales which are used for *both* downloading the `strings.xml` files from GlotPress *and* for generating the release notes XML files. |
12 | 12 | { glotpress: 'ar', android: 'ar', google_play: 'ar', promo_config: {} }, |
13 | 13 | { glotpress: 'de', android: 'de', google_play: 'de-DE', promo_config: {} }, |
14 | | - { glotpress: 'en-gb', android: 'en-rGB', google_play: 'en-US', promo_config: {} }, |
15 | 14 | { glotpress: 'es', android: 'es', google_play: 'es-ES', promo_config: {} }, |
16 | 15 | { glotpress: 'fr', android: 'fr-rCA', google_play: 'fr-CA', promo_config: false }, |
17 | 16 | { glotpress: 'fr', android: 'fr', google_play: 'fr-FR', promo_config: {} }, |
|
209 | 208 | ##################################################################################### |
210 | 209 | desc 'Downloads translated metadata from GlotPress' |
211 | 210 | lane :download_metadata_strings do |options| |
212 | | - download_wordpress_metadata_strings(options) |
213 | | - download_jetpack_metadata_strings(options) |
214 | | - end |
215 | | - |
216 | | - desc "Downloads WordPress's translated metadata from GlotPress" |
217 | | - lane :download_wordpress_metadata_strings do |options| |
218 | | - app_values = APP_SPECIFIC_VALUES[:wordpress] |
219 | | - values = options[:version].split('.') |
220 | | - files = { |
221 | | - "release_note_#{values[0]}#{values[1]}" => { desc: "changelogs/#{options[:build_number]}.txt", max_size: 500, alternate_key: "release_note_short_#{values[0]}#{values[1]}" }, |
222 | | - play_store_app_title: { desc: 'title.txt', max_size: 30 }, |
223 | | - play_store_promo: { desc: 'short_description.txt', max_size: 80 }, |
224 | | - play_store_desc: { desc: 'full_description.txt', max_size: 4000 } |
225 | | - } |
226 | | - |
227 | | - delete_old_changelogs(app: 'wordpress', build: options[:build_number]) |
228 | | - download_path = File.join(Dir.pwd, app_values[:metadata_dir], 'android') |
229 | | - # The case for the source locale (en-US) is pulled in a hacky way, by having an {en-gb => en-US} mapping as part of the WP_RELEASE_NOTES_LOCALES, |
230 | | - # which is then treated in a special way by gp_downloadmetadata by specifying a `source_locale: 'en-US'` to process it differently from the rest. |
231 | | - gp_downloadmetadata( |
232 | | - project_url: app_values[:glotpress_metadata_project], |
233 | | - target_files: files, |
234 | | - locales: WP_RELEASE_NOTES_LOCALES, |
235 | | - source_locale: 'en-US', |
236 | | - download_path: download_path |
237 | | - ) |
238 | | - |
239 | | - git_add(path: download_path) |
240 | | - git_commit(path: download_path, message: "Update WordPress metadata translations for #{options[:version]}", allow_nothing_to_commit: true) |
241 | | - push_to_git_remote |
242 | | - end |
243 | | - |
244 | | - desc "Downloads Jetpack's translated metadata from GlotPress" |
245 | | - lane :download_jetpack_metadata_strings do |options| |
246 | | - UI.message('Hey') |
247 | | - app_values = APP_SPECIFIC_VALUES[:jetpack] |
248 | | - values = options[:version].split('.') |
249 | | - files = { |
250 | | - "release_note_#{values[0]}#{values[1]}" => { desc: "changelogs/#{options[:build_number]}.txt", max_size: 500, alternate_key: "release_note_short_#{values[0]}#{values[1]}" }, |
251 | | - play_store_app_title: { desc: 'title.txt', max_size: 30 }, |
252 | | - play_store_promo: { desc: 'short_description.txt', max_size: 80 }, |
253 | | - play_store_desc: { desc: 'full_description.txt', max_size: 4000 } |
254 | | - } |
255 | | - |
256 | | - delete_old_changelogs(app: 'jetpack', build: options[:build_number]) |
257 | | - download_path = File.join(Dir.pwd, app_values[:metadata_dir], 'android') |
258 | | - gp_downloadmetadata( |
259 | | - project_url: app_values[:glotpress_metadata_project], |
260 | | - target_files: files, |
261 | | - locales: JP_RELEASE_NOTES_LOCALES, |
262 | | - download_path: download_path |
263 | | - ) |
264 | | - |
265 | | - # For WordPress, the en-US release notes come from using the source keys (instead of translations) downloaded from GlotPress' en-gb locale (which is unused otherwise). |
266 | | - # But for Jetpack, we don't have an unused locale like en-gb in the GP release notes project, so copy from source instead as a fallback |
267 | | - metadata_source_dir = File.join(Dir.pwd, '..', 'WordPress', 'jetpack_metadata') |
268 | | - FileUtils.cp(File.join(metadata_source_dir, 'release_notes.txt'), File.join(download_path, 'en-US', 'changelogs', "#{options[:build_number]}.txt")) |
269 | | - FileUtils.cp( |
270 | | - ['title.txt', 'short_description.txt', 'full_description.txt'].map { |f| File.join(metadata_source_dir, f) }, |
271 | | - File.join(download_path, 'en-US') |
272 | | - ) |
| 211 | + version = options.fetch(:version, android_get_app_version) |
| 212 | + build_number = options.fetch(:build_number, android_get_release_version['code']) |
| 213 | + |
| 214 | + # If no `app:` is specified, call this for both WordPress and Jetpack |
| 215 | + apps = options[:app].nil? ? %i[wordpress jetpack] : Array(options[:app]&.downcase&.to_sym) |
| 216 | + |
| 217 | + apps.each do |app| |
| 218 | + app_values = APP_SPECIFIC_VALUES[app] |
| 219 | + |
| 220 | + version_suffix = version.split('.').join |
| 221 | + files = { |
| 222 | + "release_note_#{version_suffix}" => { desc: "changelogs/#{build_number}.txt", max_size: 500, alternate_key: "release_note_short_#{version_suffix}" }, |
| 223 | + play_store_app_title: { desc: 'title.txt', max_size: 30 }, |
| 224 | + play_store_promo: { desc: 'short_description.txt', max_size: 80 }, |
| 225 | + play_store_desc: { desc: 'full_description.txt', max_size: 4000 } |
| 226 | + } |
| 227 | + |
| 228 | + delete_old_changelogs(app: app, build: build_number) |
| 229 | + |
| 230 | + download_path = File.join(Dir.pwd, app_values[:metadata_dir], 'android') |
| 231 | + locales = { wordpress: WP_RELEASE_NOTES_LOCALES, jetpack: JP_RELEASE_NOTES_LOCALES }[app] |
| 232 | + UI.header("Downloading metadata translations for #{app_values[:display_name]}") |
| 233 | + gp_downloadmetadata( |
| 234 | + project_url: app_values[:glotpress_metadata_project], |
| 235 | + target_files: files, |
| 236 | + locales: locales, |
| 237 | + download_path: download_path |
| 238 | + ) |
273 | 239 |
|
274 | | - git_add(path: download_path) |
275 | | - git_commit(path: download_path, message: "Update Jetpack metadata translations for #{options[:version]}", allow_nothing_to_commit: true) |
| 240 | + # Copy the source `.txt` files (used as source of truth when we generated the `.po`) to the `fastlane/*metadata/android/en-US` dir, |
| 241 | + # as `en-US` is the source language, and isn't exported from GlotPress during `gp_downloadmetadata` |
| 242 | + metadata_source_dir = File.join(PROJECT_ROOT_FOLDER, 'WordPress', app_values[:metadata_dir]) |
| 243 | + FileUtils.cp(File.join(metadata_source_dir, 'release_notes.txt'), File.join(download_path, 'en-US', 'changelogs', "#{build_number}.txt")) |
| 244 | + FileUtils.cp( |
| 245 | + ['title.txt', 'short_description.txt', 'full_description.txt'].map { |f| File.join(metadata_source_dir, f) }, |
| 246 | + File.join(download_path, 'en-US') |
| 247 | + ) |
| 248 | + |
| 249 | + git_add(path: download_path) |
| 250 | + git_commit(path: download_path, message: "Update #{app_values[:display_name]} metadata translations for #{version}", allow_nothing_to_commit: true) |
| 251 | + end |
276 | 252 | push_to_git_remote |
277 | 253 | end |
278 | 254 |
|
|
0 commit comments