Sha256: 6514311e39aef7e54406e038bbe6e7a88ce210ee975135e6bcc7f6f70527f1be
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
# desc "Explaining what the task does" # task :gettext_simple_rails do # # Task goes here # end 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.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.1 | lib/tasks/gettext_simple_rails_tasks.rake |