2013-03-10 39 views
5

Tôi không quản lý để thay đổi thông báo lỗi mặc định từ biểu mẫu đơn giản, tôi đã cố chỉnh sửa tệp cục bộ biểu mẫu đơn giản nhưng dường như bị bỏ quaThay đổi thông báo lỗi mặc định bằng simple_form

Đây là tệp ngôn ngữ của tôi:

#config/locales/simple_form.en.yml 
en: 
    simple_form: 
    error_notification: 
     default_message: "A custom message:" 

Nhưng tôi vẫn nhận được "Vui lòng xem lại vấn đề dưới đây:"

có ai biết những gì tôi đang làm sai?

+0

Bạn có khởi động lại ứng dụng sau khi thay đổi tập tin đó không? – Hesham

+0

Có, không thành công .. – vdaubry

+0

Lạ. Làm việc cho tôi. Tôi đang sử dụng simple_form 2.1.0. – Hesham

Trả lời

1

Thay đổi của bạn :default_message-:your_model_name

Như bạn thấy in the source, error_notification phương pháp sử dụng translate_error_notification để có được dịch từ file YAML.

def translate_error_notification 
    lookups = [] 
    lookups << :"#{object_name}" 
    lookups << :default_message 
    lookups << "Please review the problems below:" 
    I18n.t(lookups.shift, scope: :"simple_form.error_notification", default: lookups) 
end 

Đối user mô hình lookups chứa:

lookups == [:user, :default_messge, "Please review the problems below:] 

dịch có thể là differrent cho từng đối tượng để giao dịch này được gọi là:

#config/locales/simple_form.en.yml 
en: 
    simple_form: 
    error_notification: 
     user: "A custom message:" 

Vote nếu nó sẽ giúp;)

Các vấn đề liên quan