I have Rails I18n en.yml file which contains values with or without qoutes.
I want to change this file programmatically, but if I use Psych#load and Psych#dump approach it removes all the quotes from values. I don't want to change styling of existing values, how can I do that?
As I understand parsing the ast is the way, but I want to preserve simplicity of working with YAML as the hash and then simply dump it back as the original file but with a few new key/values.
I have Rails I18n
en.yml
file which contains values with or without qoutes.I want to change this file programmatically, but if I use
Psych#load
andPsych#dump
approach it removes all the quotes from values. I don't want to change styling of existing values, how can I do that?As I understand parsing the ast is the way, but I want to preserve simplicity of working with YAML as the hash and then simply dump it back as the original file but with a few new key/values.
Input:
Expected result (all styling preserved, new key added):