Yaml使用键作为块和值
我不知道我所寻找的是否可能,但我有以下YAMLYaml使用键作为块和值,yaml,rails-i18n,Yaml,Rails I18n,我不知道我所寻找的是否可能,但我有以下YAML en: log: model1: update: description: "My description for update" variable1: "something" variable2: "something else" model2: update: descri
en:
log:
model1:
update:
description: "My description for update"
variable1: "something"
variable2: "something else"
model2:
update:
description: "My description for update"
variable3: "another thing"
variable4: "still different"
我希望能够用这个替换这个t(“log.model1.update.description)”
,以获得相同的结果
t(“log.model1.update”)
以后仍然可以执行此操作t(“log.model1.update.variable1)
我希望避免为每个模型的每个操作创建描述码
这是一种更干燥的方法吗?YAML 1.1有一个可选选项,可以这样工作:
en:
日志:
模式1:
更新:
=:“我的更新说明”
变量1:“某物”
变量2:“其他东西”
模式2:
更新:
=:“我的更新说明”
变量3:“另一件事”
变量4:“仍然不同”
这不太可能是开箱即用的支持(虽然我不知道–欢迎尝试),但由于这是有效的YAML,您可以使用此想法将查询缩短为t(“log.model1.update.=”)