键被覆盖时的 I18n 警告
I18n warning when key is overriden
是否可以从 I18n 获得警告,当一个键已经定义时,文件之间的合并会覆盖另一个键?
例如,我们有这两个文件:
hello.de.yml
de:
hello:
world: test1
foo: bar
world.de.yml
de:
hello: Hello world
当我调用 I18n.t("hello")
时,我从 world.de.yml
文件中得到 "Hello world"
,因为它会覆盖整个密钥并且不会像在对象位于 hello
键后面。
Is it possible to raise an error, when a key is overwritten and not deep merged?
在长 YAML 文件中也会出现类似的问题,但这不在 I18n 中,我认为它在解析器中。考虑这个文件:
de:
hello:
foo: foo
hello:
bar: bar
这里,I18n.t("hello")
returns {:bar=>"bar"}
(在Ruby中解析)因为最后一个键"wins"。我认为这是一个 YAML 功能,您可以重新定义键和覆盖键,但如果发生这种情况,最好发出警告。 Ruby YAML 解析器(或 Psych)可以做类似的事情吗?我还没有找到相应的选项。
是否可以从 I18n 获得警告,当一个键已经定义时,文件之间的合并会覆盖另一个键?
例如,我们有这两个文件:
hello.de.yml
de:
hello:
world: test1
foo: bar
world.de.yml
de:
hello: Hello world
当我调用 I18n.t("hello")
时,我从 world.de.yml
文件中得到 "Hello world"
,因为它会覆盖整个密钥并且不会像在对象位于 hello
键后面。
Is it possible to raise an error, when a key is overwritten and not deep merged?
在长 YAML 文件中也会出现类似的问题,但这不在 I18n 中,我认为它在解析器中。考虑这个文件:
de:
hello:
foo: foo
hello:
bar: bar
这里,I18n.t("hello")
returns {:bar=>"bar"}
(在Ruby中解析)因为最后一个键"wins"。我认为这是一个 YAML 功能,您可以重新定义键和覆盖键,但如果发生这种情况,最好发出警告。 Ruby YAML 解析器(或 Psych)可以做类似的事情吗?我还没有找到相应的选项。