Why do some of my (Rails) language files have a triple dash (---)?

In some project language files, I am currently working on finding a triple dash in the first line.

Same:

--- de: activerecord: user: 

In most local files, they are not there. They all work as expected. Dashes seem to be in the original Rails locales, but since we have almost no remains, this is just an assumption.

Any ideas they come from and what is the effect?

+6
source share
1 answer

YAML uses three dashes ("---") to separate directives from the contents of a document. It also serves to signal the start of a document if there are no directives.

So, if you have several documents per YAML file, you should separate them into three dashes. If you have only one document, you can delete / omit it (I never had a problem with YAML in ruby ​​if three dashes were missing). The reason she added when you yamlify your object is that, I think, the dump truck is written “by specification” and does not want to implement such “shortcuts” (omitted three times when it is only one document).

+7
source

Source: https://habr.com/ru/post/1014247/


All Articles