Module: GettextI18nRails

### Home Classes Methods

### In Files

- lib/gettext_i18n_rails.rb
- lib/gettext_i18n_rails/backend.rb
- lib/gettext_i18n_rails/base_parser.rb
- lib/gettext_i18n_rails/gettext_hooks.rb
- lib/gettext_i18n_rails/haml_parser.rb
- lib/gettext_i18n_rails/html_safe_translations.rb
- lib/gettext_i18n_rails/model_attributes_finder.rb
- lib/gettext_i18n_rails/railtie.rb
- lib/gettext_i18n_rails/slim_parser.rb
- lib/gettext_i18n_rails/version.rb

### Namespace

- MODULE GettextI18nRails::GettextHooks
- MODULE GettextI18nRails::HtmlSafeTranslations
- CLASS GettextI18nRails::Backend
- CLASS GettextI18nRails::BaseParser
- CLASS GettextI18nRails::HamlParser
- CLASS GettextI18nRails::ModelAttributesFinder
- CLASS GettextI18nRails::Railtie
- CLASS GettextI18nRails::SlimParser

### Methods

- ::store_model_attributes

### Class/Module Index

Quicksearch

- GettextI18nRails
- GettextI18nRails::Backend
- GettextI18nRails::BaseParser
- GettextI18nRails::GettextHooks
- GettextI18nRails::HamlParser
- GettextI18nRails::HtmlSafeTranslations
- GettextI18nRails::ModelAttributesFinder
- GettextI18nRails::Railtie
- GettextI18nRails::SlimParser
- RubyGettextExtractor
- RubyGettextExtractor::Extractor18
- RubyGettextExtractor::Extractor19
- RubyGettextExtractor::ExtractorMethods
- ActionController
- ActionController::Base
- ActiveModel
- ActiveModel::Translation
- ActiveRecord
- ActiveRecord::Base
- I18n
- I18n::Config
- Object
- String

No matching classes.

# GettextI18nRails

### Constants

IGNORE_TABLES
Version

### Public Class Methods

store_model_attributes(options) click to toggle source

write all found models/columns to a file where GetTexts ruby parser can find them

    # File lib/gettext_i18n_rails/model_attributes_finder.rb, line 6
    def store_model_attributes(options)
      file = options[:to] || 'locale/model_attributes.rb'
      begin
        File.open(file,'w') do |f|
          f.puts "#DO NOT MODIFY! AUTOMATICALLY GENERATED FILE!"
          ModelAttributesFinder.new.find(options).each do |model,column_names|
            f.puts("_('#{model.humanize_class_name}')")

            #all columns namespaced under the model
            column_names.each do |attribute|
              translation = model.gettext_translation_for_attribute_name(attribute)
              f.puts("_('#{translation}')")
            end
          end
          f.puts "#DO NOT MODIFY! AUTOMATICALLY GENERATED FILE!"
        end
      rescue
        puts "[Error] Attribute extraction failed. Removing incomplete file (#{file})"
        File.delete(file)
        raise
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.