How to add values dynamically to I18n?

Posted by Dima Goltsman on Stack Overflow See other posts from Stack Overflow or by Dima Goltsman
Published on 2014-08-19T15:09:38Z Indexed on 2014/08/19 16:20 UTC
Read the original article Hit count: 306

I have many ymls in my rails app, and i want to put some of them in other service, so that i can call this from multiple places. the response of this call will be a hash.

{"en" : 
  {"test" : 
    {"text1" : "hi english"},
    {"text2" : "mambo number %{num}"}
  },
 "es" : 
  {"test" : 
    {"text1" : "hi espaniol"},
    {"text2" : "mamboes numeros %{num}"}
  }
}

is there a way i can load that hash into I18n translations like

I18n.add_translations(some_hash)

so i can access them with

I18n.t("test.text1")
I18n.t("test.text2", :num => 5)

how can i achieve it?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby