2010-05-31 65 views
0

我在尝试在Rails 2.3.5应用程序中转换模型的名称和属性时遇到了一些问题。Rails 2.3.5错误消息中的模型名称转换问题

我有以下型号:

class BillingPlan < ActiveRecord::Base 

    validates_presence_of :billing_option_id 

    belongs_to :order 
    belongs_to :user 
    belongs_to :billing_option 
end 

验证失败时,我的模型属性翻译正确,但MODELNAME本身是没有的。我用de.yml

de: 
    activerecord: 
    models: 
     shipping_plan: "Versandart" 
     billing_plan: "Rechnungsart" 
    attributes: 
     shipping_plan: 
     shipping_option_id: "Versandoption" 
     billing_plan: 
     billing_option_id: "Rechnungsoption" 

依据下列转换骨架为我的翻译文件为:http://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/de.yml

谁能帮助?

提前 J.

+0

如何调用错误? '通过error_message_for'? – shingara 2010-05-31 16:57:26

+0

这里变得更加混乱。我对大多数表格都使用formtastic,但也必须使用标准表格。 如果我使用类似formtastic: <%semantic_form_for @user do | f | %> <%= f.error_messages%> ... <% end %>一切都翻译得很好。 如果是标准格式: <%form_for @billing_plan do | f | %> <%= f.error_messages%> ... <% end %>我仍然有模型名称未翻译的问题。 – 2010-05-31 20:35:11

回答

0

尝试检查你的翻译活动记录模型,看看国际化的文档,在导轨指南5.1.3节THX(http://guides.rubyonrails.org/i18n.html

默认轨使用此,您应该为您的i18n创建一个:

en: 
    activerecord: 
    errors: 
     template: 
     header: 
      one: "1 error prohibited this {{model}} from being saved" 
      other: "{{count}} errors prohibited this {{model}} from being saved" 
     body: "There were problems with the following fields:" 
+0

哦,我看到这些翻译已经在http://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/de.yml中实现,或许我的awnser并没有太大帮助 – vrsmn 2010-05-31 18:02:15

+0

似乎成为一个更难的问题。无论如何。 – 2010-05-31 20:35:34