Sha256: dfd6c4073252b285bbf57c5fe27e0ef1ed7a9fef1b6e5354c0ffd1c520694370
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
namespace :gettext_simple_rails do task "generate_model_translation_files" => :environment do GettextSimpleRails::ModelInspector.model_classes do |inspector| translation_path = "#{GettextSimpleRails.translation_dir}/models/#{inspector.snake_name}_model_translations.rb" FileUtils.mkdir_p(File.dirname(translation_path)) unless File.exists?(File.dirname(translation_path)) File.open(translation_path, "w") do |fp| fp.puts "class GettextSimpleRails::UserModelTranslations" fp.puts " def self.attribute_translations" inspector.attributes do |attribute| fp.puts " puts _('#{attribute.gettext_key}')" end fp.puts " end" fp.puts "" fp.puts " def self.relationship_translations" inspector.relationships do |name, relationship| fp.puts " puts _('#{inspector.relationship_gettext_key(name)}')" end fp.puts " end" fp.puts "" fp.puts " def self.paperclip_attachments" inspector.paperclip_attachments do |name| fp.puts " puts _('#{inspector.relationship_gettext_key(name)}')" end fp.puts " end" fp.puts "" fp.puts " def self.model_name" fp.puts " puts _('#{inspector.gettext_key}.one')" fp.puts " puts _('#{inspector.gettext_key}.other')" fp.puts " end" fp.puts "end" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gettext_simple_rails-0.0.2 | lib/tasks/gettext_simple_rails_tasks.rake |