加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Active Record是否有默认的英文翻译文件?

发布时间:2020-12-17 04:24:54 所属栏目:百科 来源:网络整理
导读:我正在将应用程序的rails应用程序升级到2.3.2,我发现我无法显示ActiveRecord的默认验证错误消息,因为我没有它的转换文件. 这是报告的错误: translation missing: en-US,activerecord,errors,template,headertranslation missing: en-US,bodyEmail translati
我正在将应用程序的rails应用程序升级到2.3.2,我发现我无法显示ActiveRecord的默认验证错误消息,因为我没有它的转换文件.

这是报告的错误:

translation missing: en-US,activerecord,errors,template,header
translation missing: en-US,body
Email translation missing: en-US,models,user,attributes,email,taken

有谁知道我在哪里可以找到一个默认的英文翻译文件,其中包含验证可能使用的所有字符串?

解决方法

发生这种情况是因为我的语言环境是“en-US”而不是“en”. activerecord / lib / locale下有翻译文件.我将这些翻译复制到一个新文件en_US.yml中.
"en-US": 
  activerecord:
    errors: 
        template: 
            body: There were problems with the following fields
            header: 
                one: 1 error prohibited this {{model}} from being saved
                other: "{{count}} errors prohibited this {{model}} from being saved"  
        messages:
            inclusion: "is not included in the list"
            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 {{count}} characters)"
            too_short: "is too short (minimum is {{count}} characters)"
            wrong_length: "is the wrong length (should be {{count}} characters)"
            taken: "has already been taken"
            not_a_number: "is not a number"
            greater_than: "must be greater than {{count}}"
            greater_than_or_equal_to: "must be greater than or equal to {{count}}"
            equal_to: "must be equal to {{count}}"
            less_than: "must be less than {{count}}"
            less_than_or_equal_to: "must be less than or equal to {{count}}"
            odd: "must be odd"
            even: "must be even"

然后我在这些之后添加了自定义字符串.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读