How to retrieve all translations from yml files in Rails I18n

前端 未结 6 1149
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:21

    As per 8xx8's comment, a simpler version of:

    I18n.t(:foo)
    I18n.backend.send(:translations)[:en][:test_string]
    

    is

    I18n.t(".")[:test_string]
    

    This mitigates having to both preload the translations or specify the locale.

提交回复
热议问题