问题描述
我不知道我要找的东西是否可行,但我有以下 YAML
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 有一个可选的 value key,其工作方式如下:
en:
log:
model1:
update:
=: "My description for update"
variable1: "something"
variable2: "something else"
model2:
update:
=: "My description for update"
variable3: "another thing"
variable4: "still different"
这不太可能是开箱即用的(虽然我不知道 - 欢迎尝试)但由于这是有效的 YAML,您可以使用这个想法将您的查询缩短为 {{1} }.