ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

I18n patches break standard Rails behavior (Bug #297)


Added by Ivan Evtuhovich at 2011-03-19 02:41 pm.


Status:Open Start date:2011-03-19
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
Remote issue URL: Affected version:

Description

I think I18n brokes standard rails behavior.

I've tried to translate repository/git url attribute in a standard rails way, adding:


  activerecord:
    models:
      repository/git:
        attributes:
          url: Path to git repository

But there an error occur, when i try to save git repo with empty url:


ActionView::TemplateError (translation data {:attributes=>{:url=>"Path to git repository"}} can not be used with :count => 1) on line #6 of app/views/projects/settings/_repository.rhtml:
3:                    :builder => TabularFormBuilder,
4:                    :lang => current_language do |f| %>
5: 
6: <%= error_messages_for 'repository' %>
7: 
8: <div class="box tabular">
9: <p><%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(@repository) %></p>

    /home/brun/.rvm/gems/ruby-1.8.7-p334/gems/i18n-0.4.2/lib/i18n/backend/base.rb:138:in `pluralize'
    /home/brun/.rvm/gems/ruby-1.8.7-p334/gems/i18n-0.4.2/lib/i18n/backend/base.rb:45:in `translate'
    /home/brun/.rvm/gems/ruby-1.8.7-p334/gems/i18n-0.4.2/lib/i18n/backend/fallbacks.rb:47:in `translate'
    /home/brun/.rvm/gems/ruby-1.8.7-p334/gems/i18n-0.4.2/lib/i18n/backend/fallbacks.rb:45:in `each'
    /home/brun/.rvm/gems/ruby-1.8.7-p334/gems/i18n-0.4.2/lib/i18n/backend/fallbacks.rb:45:in `translate'
    /home/brun/.rvm/gems/ruby-1.8.7-p334/gems/i18n-0.4.2/lib/i18n.rb:160:in `translate'
    config/initializers/10-patches.rb:36:in `full_messages'
    config/initializers/10-patches.rb:21:in `each'
    config/initializers/10-patches.rb:21:in `full_messages'
    config/initializers/10-patches.rb:20:in `full_messages'

And the other problem with TabularFormBuilder#label_for_field - it isn't render translated name for AR attributes.

source:config/initializers/10-patches.rb#L10

1    def self.human_attribute_name(attr)
2      l("field_#{attr.to_s.gsub(/_id$/, '')}")
3    end

Therefore it translates url field in all models as a 'URL'. I think this behavior is unclear for most rails developers


History

Also available in: Atom PDF