2010-05-31 67 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