繁体   English   中英

活动记录翻译时出错

[英]Error with active Record translations

db:reset时出现错误。 我已经阅读了几篇关于此的文章,但没有一篇对我有用。

错误提示:

translation missing: es.activerecord.errors.messages.record_invalid

我的locales/es.yml是:

es:
  activerecord:
    errors:
      messages:
        accepted: "must be accepted"
        blank: "can't be blank"
        confirmation: "doesn't match confirmation"
        empty: "can't be empty"
        equal_to: "must be equal to {{count}}"
        even: "must be even"
        exclusion: "is reserved"
        greater_than: "must be greater than {{count}}"
        greater_than_or_equal_to: "must be greater than or equal to {{count}}"
        inclusion: "is not included in the list"
        invalid: "is invalid"
        less_than: "must be less than {{count}}"
        less_than_or_equal_to: "must be less than or equal to {{count}}"
        not_a_number: "is not a number"
        odd: "must be odd"
        taken: "is already taken"
        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)"

通过将Rails语言环境存储库中的所有语言环境翻译复制到我的es.yml中,进行了修复。

https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/es.yml

如果您安装rails-i18n gem,它将自动将其包含在rails应用程序中。

rails-i18n gem自述文件:

添加到您的Gemfile:

gem 'rails-i18n', '~> 5.1' # For 5.0.x, 5.1.x and 5.2.x
gem 'rails-i18n', '~> 4.0' # For 4.0.x
gem 'rails-i18n', '~> 3.0' # For 3.x
gem 'rails-i18n', github: 'svenfuchs/rails-i18n', branch: 'master' # For 5.x
gem 'rails-i18n', github: 'svenfuchs/rails-i18n', branch: 'rails-4-x' # For 4.x
gem 'rails-i18n', github: 'svenfuchs/rails-i18n', branch: 'rails-3-x' # For 3.x

或运行以下命令:

gem install rails-i18n -v '~> 5.1' # For  For 5.0.x, 5.1.x and 5.2.x
gem install rails-i18n -v '~> 4.0' # For 4.0.x
gem install rails-i18n -v '~> 3.0' # For 3.x

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM