用于en.yml文件的字符串常量

时间:2015-03-21 00:33:44

标签: ruby-on-rails

在我的locales / en.yml中,我有以下内容:

en:
  activerecord:
    attributes:
      ticket:
        customer_name: "Customer Name"
      inventory:
        quantity: 'Quantity'
      resources:
        quantity: 'Quantity'
      hours:
        quantity: 'Quantity'

我有没有办法定义字符串' Quantity'作为一个字符串常量,所以我可以在我的en.yml中重复使用常量?

1 个答案:

答案 0 :(得分:3)

示例:

default: &default
  adapter: mysql2
  encoding: utf8
  username: username
  password: YOURDBPASSWORD

development:
  <<: *default

test:
  <<: *default

另见答案:Reuse a block of code in YAML