Module: GettextI18nRails
- Extended by:
- GettextI18nRails
- Included in:
- GettextI18nRails
- Defined in:
- lib/gettext_i18n_rails.rb,
lib/gettext_i18n_rails/backend.rb,
lib/gettext_i18n_rails/railtie.rb,
lib/gettext_i18n_rails/haml_parser.rb,
lib/gettext_i18n_rails/html_safe_translations.rb,
lib/gettext_i18n_rails/model_attributes_finder.rb
Defined Under Namespace
Modules: HamlParser, HtmlSafeTranslations Classes: Backend, ModelAttributesFinder, Railtie
Constant Summary collapse
- VERSION =
File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
Class Method Summary collapse
-
.store_model_attributes(options) ⇒ Object
write all found models/columns to a file where GetTexts ruby parser can find them.
Class Method Details
.store_model_attributes(options) ⇒ Object
write all found models/columns to a file where GetTexts ruby parser can find them
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gettext_i18n_rails/model_attributes_finder.rb', line 3 def store_model_attributes() file = [:to] || 'locale/model_attributes.rb' File.open(file,'w') do |f| f.puts "#DO NOT MODIFY! AUTOMATICALLY GENERATED FILE!" ModelAttributesFinder.new.find().each do |table_name,column_names| #model name begin model = table_name.singularize.camelcase.constantize rescue NameError # Some tables are not models, for example: translation tables created by globalize2. next end f.puts("_('#{model.human_name_without_translation}')") #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 end |