This is above me today. Hope someone can explain this to me!
Assume you have a rails project with a en.yml file with the following contents:
en:
foo:
foo: foo
bar: bar
Assigning the results of I18n.t(:foo) to a local variable, you get a Hash:
2.0.0-p353 :001 > a = I18n.t(:foo)
=> {:foo=>"foo", :bar=>"bar"}
And now, changing a value for a key in this Hash causes changes in I18n.t('foo.foo'):
2.0.0-p353 :005 > a[:foo] = 'bar'
=> "bar"
2.0.0-p353 :006 > I18n.t(:foo)
=> {:foo=>"bar", :bar=>"bar"}
So, for the question to be clear - why changing a[:foo] from 'foo' to 'bar', causes the changes in I18n.t('foo.foo')?
Thanks in advance!