diff options
author | José Valim <jose.valim@gmail.com> | 2011-06-08 05:01:24 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-06-08 05:01:24 -0700 |
commit | b64524d6fdacdd03277efd7b12ff0e8fa97737e2 (patch) | |
tree | f8ff6e346eae4560e6d7a0112abcc99c0704455c /activemodel/lib | |
parent | 8c1762f11e4c2b32a0aff6cbda27f359d8c9d31c (diff) | |
parent | 0831b7e076af1ecae41a55dd82cb0582b96518a0 (diff) | |
download | rails-b64524d6fdacdd03277efd7b12ff0e8fa97737e2.tar.gz rails-b64524d6fdacdd03277efd7b12ff0e8fa97737e2.tar.bz2 rails-b64524d6fdacdd03277efd7b12ff0e8fa97737e2.zip |
Merge pull request #1556 from thoefer/master
Brought back alternative convention for namespaced models in i18n
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 7 | ||||
-rw-r--r-- | activemodel/lib/active_model/translation.rb | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index 4c1a82f413..c7b9c41f46 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -21,7 +21,7 @@ module ActiveModel @partial_path = "#{@collection}/#{@element}".freeze @param_key = (namespace ? _singularize(@unnamespaced) : @singular).freeze @route_key = (namespace ? ActiveSupport::Inflector.pluralize(@param_key) : @plural).freeze - @i18n_key = self.underscore.to_sym + @i18n_key = self.underscore.tr('/', '.').to_sym end # Transform the model name into a more humane format, using I18n. By default, @@ -35,8 +35,9 @@ module ActiveModel @klass.respond_to?(:i18n_scope) defaults = @klass.lookup_ancestors.map do |klass| - klass.model_name.i18n_key - end + [klass.model_name.i18n_key, + klass.model_name.i18n_key.to_s.tr('.', '/').to_sym] + end.flatten defaults << options[:default] if options[:default] defaults << @human diff --git a/activemodel/lib/active_model/translation.rb b/activemodel/lib/active_model/translation.rb index 6d64c81b5f..c615311692 100644 --- a/activemodel/lib/active_model/translation.rb +++ b/activemodel/lib/active_model/translation.rb @@ -44,8 +44,9 @@ module ActiveModel # Specify +options+ with additional translating options. def human_attribute_name(attribute, options = {}) defaults = lookup_ancestors.map do |klass| - :"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}.#{attribute}" - end + [:"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}.#{attribute}", + :"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key.to_s.tr('.', '/')}.#{attribute}"] + end.flatten defaults << :"attributes.#{attribute}" defaults << options.delete(:default) if options[:default] |