How to retrieve all translations from yml files in Rails I18n

前端 未结 6 1172
Happy的楠姐
Happy的楠姐 2020-12-24 11:38

I\'m guessing that rails stores all the parsed translations yml files in a sort of array/hash. Is there a way to access this?

For example, if I\'ve a file:



        
6条回答
  •  被撕碎了的回忆
    2020-12-24 12:17

    You got to call a private method on the backend. This is how you get access:

    translations = I18n.backend.send(:translations)
    translations[:en][:test_string] # => "testing this"
    

提交回复
热议问题