×

yaml 的百分号(%) 解析出错

Falcon 2020-01-16 views:
自动摘要

正在生成中……

问题:

I'm getting an error with .yml translation file for symfony. Here is my file(date.it.yml).

diff.ago.year: un anno fa | %count% anni fa
diff.ago.month: un mese fa | %count% mesi fa
diff.ago.day: %count% giorno fa | %count% giorni fa
diff.ago.hour: un'ora fa | %count% ore fa
diff.ago.minute: 1 minuto fa | %count% minuti fa

Think this line gives me error. un anno fa | %count% anni fa.

This is my error,

Error parsing YAML, invalid file "C:\wamp64\www\swapp/translations\date.it.yml"

It would be great if someone can help. Thanks in advance.

回答:

% is invalid at the start of a plain string in YAML.

So this line:

diff.ago.day: %count% giorno fa | %count% giorni fa

is invalid and needs quotes:

diff.ago.day: '%count% giorno fa | %count% giorni fa'

Now if you had additionally a single quote inside of this string, you would double it. Or you could use double quotes.