diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index 91d476b51..d72e470b6 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