Skip to content

Instantly share code, notes, and snippets.

@giacomomacri
Created October 10, 2012 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giacomomacri/3865455 to your computer and use it in GitHub Desktop.
Save giacomomacri/3865455 to your computer and use it in GitHub Desktop.
Add Models Attribute on LocaleApp
namespace :localeapp do
desc "Usage: rake localeapp:add_models_keys['Model1 Model2 Model3']"
task :add_models_keys, [:models] => :environment do |task, args|
models = args[:models].split(' ')
models.each do |model|
model_attributes = model.constantize.attribute_names - %w(id)
I18n.available_locales.each do |locale|
model_attributes.each do |at|
key = "activerecord.attributes.#{model.downcase}.#{at}"
puts "Sending key: #{key} for #{locale}"
Localeapp.missing_translations.add(locale, key, nil)
end
end
end
Localeapp.sender.post_missing_translations
puts "Success!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment