syntaxyamlquotes

Do I need quotes for strings in YAML?


I am trying to write a YAML dictionary for internationalisation of a Rails project. I am a little confused though, as in some files I see strings in double-quotes and in some without. A few points to consider:

What are the rules for using the different types of quotes in YAML?

Could it be said that:


Solution

  • After a brief review of the YAML cookbook cited in the question and some testing, here's my interpretation:

    Seems to me that the best approach would be to not use quotes unless you have to, and then to use single quotes unless you specifically want to process escape codes.

    Update

    "Yes" and "No" should be enclosed in quotes (single or double) or else they will be interpreted as TrueClass and FalseClass values:

    en:
      yesno:
        'yes': 'Yes'
        'no': 'No'