Skip to content

Commit

Permalink
locale:model_display_names: automatic creation of model display names
Browse files Browse the repository at this point in the history
  • Loading branch information
mzazrivec committed May 25, 2018
1 parent df75232 commit 460d16f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/tasks/locale.rake
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,15 @@ namespace :locale do
Rake::Task['gettext:po_to_json'].invoke
system "rm -rf #{combined_dir}"
end

desc "Create display names for models"
task "model_display_names" => :environment do
f = File.open(Rails.root.join("config/model_display_names.rb"), "w+")
Rails.application.eager_load!
ApplicationRecord.descendants.sort_by(&:display_name).collect do |model|
next if model.model_name.singular.titleize != model.display_name || model.display_name.start_with?('ManageIQ')
f.puts "n_('#{model.display_name}', '#{model.display_name 2}', n)"
end
f.close
end
end

0 comments on commit 460d16f

Please sign in to comment.