20°

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

问题:

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.

本文由【FalconChen】发布于开源中国,原文链接:https://my.oschina.net/falcon10086/blog/3159312

全部评论: 0

    我有话说: