Module: GettextI18nRails
- Defined in:
- lib/gettext_i18n_rails.rb,
lib/gettext_i18n_rails/backend.rb,
lib/gettext_i18n_rails/railtie.rb,
lib/gettext_i18n_rails/version.rb,
lib/gettext_i18n_rails/base_parser.rb,
lib/gettext_i18n_rails/haml_parser.rb,
lib/gettext_i18n_rails/slim_parser.rb,
lib/gettext_i18n_rails/gettext_hooks.rb,
lib/gettext_i18n_rails/html_safe_translations.rb,
lib/gettext_i18n_rails/model_attributes_finder.rb
Defined Under Namespace
Modules: GettextHooks, HtmlSafeTranslations Classes: Backend, BaseParser, HamlParser, ModelAttributesFinder, Railtie, SlimParser
Constant Summary collapse
- IGNORE_TABLES =
[/^sitemap_/, /_versions$/, 'schema_migrations', 'sessions', 'delayed_jobs']
- Version =
VERSION = '1.13.0'
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
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gettext_i18n_rails/model_attributes_finder.rb', line 6 def store_model_attributes() file = [:to] || 'locale/model_attributes.rb' begin File.open(file,'w') do |f| f.puts "#DO NOT MODIFY! AUTOMATICALLY GENERATED FILE!" ModelAttributesFinder.new.find().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 |