rails 错误提示-中文:使用插件的方法汉化ROR错误提示信息 收藏
2009年04月09日


1.在 your_app/vendor/plugins下建立一个新的文件夹“new_errors”

2.在新建的文件夹“new_errors”下建一个“lib”的文件夹。

最后如下:

your_app/vendor/plugins/new_errors/lib

3.在“new_errors”下建立一个init.rb“文件,内容为:

require "new_errors"

4.在”lib“下新增一个叫”new_errors.rb“的文件。

内容如下:

module ActiveRecord

class Errors

@@default_error_messages = {

:inclusion => "在列表中没有包含",

:exclusion => "is reserved",

:invalid => "is invalid",

:confirmation => "doesn't match confirmation",

:accepted => "must be accepted",

:empty => "can't be empty",

:blank => "can't be blank",

:too_long => "is too long (maximum is %d characters)",

:too_short => "is too short (minimum is %d characters)",

:wrong_length => "is the wrong length (should be %d characters)",

:taken => "已经存在了",

:not_a_number => "is not a number。Numbers ars things like 12345 ok?"

}

end

end

在这里面你就可以修改错误提示信息了。

当重新启动WEBRick的时候,plugs将自动被装入。

转自:http://www.blogjava.net/zidoing/archive/2006/04/17/41500.html

 

本文永久链接: http://www.zzxj.net/blog/fxs_2008/archive/2009/04/09/35.html

发表于 @ 2009年04月09日 |评论(loading... )|收藏

发表评论 姓  名: