From 2d51ff9b6a24f64a87ed4ae47e8bfd191b102ed5 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Fri, 26 Jul 2024 13:39:50 +0200 Subject: [PATCH] Fixes #37688 - Do not build action names without actions If the file already exists but would be empty, it gets deleted. --- lib/tasks/gettext.rake | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index 91d476b51..b3c3b9ced 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -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 @@ -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}")] } + .sort + .join("\n") + "\n" + elsif File.exist? storage_file + puts "Removing empty action translations file: #{storage_file}" + File.delete storage_file + end end end