Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gettext:store_action_names #761

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions lib/tasks/gettext.rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@
namespace :gettext do
task :store_action_names => :environment do
storage_file = "#{locale_path}/action_names.rb"
klasses = Actions::EntryAction
.subclasses
.uniq
.select do |action|
src, = Object.const_source_location(action.to_s)
src.start_with? @engine.root.to_s
instances = Actions::EntryAction
.subclasses
.uniq
.map(&:allocate)
.select do |action|
[:plan, :run, :finalize].any? do |method_name|

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

View workflow job for this annotation

GitHub Actions / Rubocop / Rubocop

Performance/CollectionLiteralInLoop: Avoid immutable Array literals in loops. It is better to extract it into a local variable or a constant.
if action.respond_to?(method_name)
src, = action.method(method_name).source_location
src.start_with? @engine.root.to_s
end
end
end

if klasses.any?
if instances.any?
puts "writing action translations to: #{storage_file}"

File.write storage_file,
"# Autogenerated!\n" +
klasses
.map { |klass| %[_("#{klass.allocate.humanized_name}")] }
instances
.map { |instance| %[_("#{instance.humanized_name}")] }
.sort
.join("\n") + "\n"
elsif File.exist? storage_file
Expand Down
Loading