@@ -144,15 +144,13 @@ end
144
144
lane :generate_source_po_file do |commit_and_push_changes : false |
145
145
project_version = get_version_from_cargo_toml
146
146
147
- UI . header ( " 🔄 Converting English Fluent file to PO format" )
147
+ UI . header ( ' 🔄 Converting English Fluent file to PO format' )
148
148
149
149
FileUtils . mkdir_p ( File . dirname ( LOCALIZATION_PO_SOURCE_FILE ) )
150
150
151
151
fluent_file = File . join ( LOCALIZATION_FLUENT_FILES_DIR , 'en-US' , MAIN_FLUENT_FILE_NAME )
152
152
153
- unless File . exist? ( fluent_file )
154
- UI . user_error! ( "❌ English Fluent file not found: #{ fluent_file } " )
155
- end
153
+ UI . user_error! ( "❌ English Fluent file not found: #{ fluent_file } " ) unless File . exist? ( fluent_file )
156
154
157
155
begin
158
156
fluent_to_po (
@@ -164,14 +162,16 @@ lane :generate_source_po_file do |commit_and_push_changes: false|
164
162
)
165
163
166
164
UI . success ( "✅ #{ File . basename ( fluent_file ) } → #{ File . basename ( LOCALIZATION_PO_SOURCE_FILE ) } " )
167
- rescue => e
165
+ rescue StandardError => e
168
166
UI . error ( "❌ Failed to convert English Fluent file: #{ e . message } " )
169
167
end
170
168
171
- commit_changed_files (
172
- files : LOCALIZATION_PO_SOURCE_FILE ,
173
- message : 'Update source PO file (en-US.pot) to be synced to GlotPress'
174
- ) if commit_and_push_changes
169
+ if commit_and_push_changes
170
+ commit_changed_files (
171
+ files : LOCALIZATION_PO_SOURCE_FILE ,
172
+ message : 'Update source PO file (en-US.pot) to be synced to GlotPress'
173
+ )
174
+ end
175
175
end
176
176
177
177
# Converts a PO file for a given locale back to Fluent format
@@ -211,22 +211,20 @@ end
211
211
# @param commit_and_push_changes [Boolean] Whether to commit and push the updated Fluent files (default: false)
212
212
#
213
213
lane :download_translations do |commit_and_push_changes : false |
214
- UI . header ( " 🌐 Downloading translations from GlotPress" )
214
+ UI . header ( ' 🌐 Downloading translations from GlotPress' )
215
215
216
216
downloaded_files = download_po_files_from_glotpress
217
217
updated_fluent_files = [ ]
218
218
219
219
# Convert PO files back to Fluent format
220
220
if downloaded_files . any?
221
- UI . header ( " 🔄 Converting PO files to Fluent format" )
221
+ UI . header ( ' 🔄 Converting PO files to Fluent format' )
222
222
223
223
downloaded_files . each do |file_path |
224
- begin
225
- fluent_file_path = generate_fluent_file_from_po ( file_path : file_path )
226
- updated_fluent_files << fluent_file_path if fluent_file_path
227
- rescue => e
228
- UI . error ( "❌ Failed to convert #{ File . basename ( file_path ) } : #{ e . message } " )
229
- end
224
+ fluent_file_path = generate_fluent_file_from_po ( file_path : file_path )
225
+ updated_fluent_files << fluent_file_path if fluent_file_path
226
+ rescue StandardError => e
227
+ UI . error ( "❌ Failed to convert #{ File . basename ( file_path ) } : #{ e . message } " )
230
228
end
231
229
232
230
UI . success ( "✅ Updated Fluent files: #{ updated_fluent_files . length } locales" )
252
250
# @return [Array<String>] List of successfully downloaded files
253
251
#
254
252
lane :download_po_files_from_glotpress do |download_dir : LOCALIZATION_PO_FILES_TMP_DIR |
255
- UI . header ( " 🌐 Downloading PO files from GlotPress" )
253
+ UI . header ( ' 🌐 Downloading PO files from GlotPress' )
256
254
257
255
# Ensure PO output directory exists
258
256
FileUtils . mkdir_p ( download_dir )
@@ -275,7 +273,7 @@ lane :download_po_files_from_glotpress do |download_dir: LOCALIZATION_PO_FILES_T
275
273
else
276
274
UI . error ( "❌ Failed to download #{ project_locale } : empty response" )
277
275
end
278
- rescue => e
276
+ rescue StandardError => e
279
277
UI . error ( "❌ Failed to download #{ project_locale } : #{ e . message } " )
280
278
end
281
279
end
@@ -315,13 +313,11 @@ def get_version_from_cargo_toml
315
313
default_version = '1.0.0'
316
314
317
315
File . readlines ( cargo_toml_path ) . each do |line |
318
- if line . start_with? ( 'version = ' )
319
- return line . split ( '=' ) [ 1 ] . strip . gsub ( /["']/ , '' )
320
- end
316
+ return line . split ( '=' ) [ 1 ] . strip . gsub ( /["']/ , '' ) if line . start_with? ( 'version = ' )
321
317
end
322
318
323
319
default_version
324
- rescue
320
+ rescue StandardError
325
321
default_version
326
322
end
327
323
@@ -334,8 +330,8 @@ def commit_changed_files(files:, message:, push: true)
334
330
)
335
331
336
332
if result . nil?
337
- UI . important ( " ⚠️ No changed files" )
338
- else
339
- push_to_git_remote ( set_upstream : true , tags : false ) if push
333
+ UI . important ( ' ⚠️ No changed files' )
334
+ elsif push
335
+ push_to_git_remote ( set_upstream : true , tags : false )
340
336
end
341
337
end
0 commit comments