Skip to content

Commit

Permalink
Fixes #37688 - Do not build action names without actions
Browse files Browse the repository at this point in the history
If the file already exists but would be empty, it gets deleted.
  • Loading branch information
adamruzicka committed Jul 26, 2024
1 parent fc96018 commit 52b301d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/tasks/gettext.rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ if gettext_find_task
namespace :gettext do
task :store_action_names => :environment do
storage_file = "#{locale_path}/action_names.rb"
puts "writing action translations to: #{storage_file}"

klasses = Actions::EntryAction
.subclasses
.uniq
Expand All @@ -18,12 +16,19 @@ if gettext_find_task
src.start_with? @engine.root.to_s
end

File.write storage_file,
"# Autogenerated!\n" +
klasses
.map { |klass| %[_("#{klass.allocate.humanized_name}")] }
.sort
.join("\n") + "\n"
if klasses.any?
puts "writing action translations to: #{storage_file}"

File.write storage_file,
"# Autogenerated!\n" +
klasses
.map { |klass| %[_("#{klass.allocate.humanized_name}")] }

Check failure on line 25 in lib/tasks/gettext.rake

View workflow job for this annotation

GitHub Actions / Rubocop / Rubocop

Layout/MultilineMethodCallIndentation: Align `.map` with `klasses` on line 24.
.sort

Check failure on line 26 in lib/tasks/gettext.rake

View workflow job for this annotation

GitHub Actions / Rubocop / Rubocop

Layout/MultilineMethodCallIndentation: Align `.sort` with `klasses` on line 24.
.join("\n") + "\n"

Check failure on line 27 in lib/tasks/gettext.rake

View workflow job for this annotation

GitHub Actions / Rubocop / Rubocop

Layout/MultilineMethodCallIndentation: Align `.join` with `klasses` on line 24.
elsif File.exist? storage_file
puts "Removing empty action translations file: #{storage_file}"
File.delete storage_file
end
end
end

Expand Down

0 comments on commit 52b301d

Please sign in to comment.