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

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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
24 changes: 15 additions & 9 deletions lib/tasks/gettext.rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,27 @@ if gettext_find_task
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
method_names = [:plan, :run, :finalize]
instances = Actions::EntryAction
.descendants
.uniq
.map(&:allocate)
.select do |action|
method_names.any? do |method_name|
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