@kyanny's blog

My thoughts, my life. Views/opinions are my own.

Ruby の i18n gem を pry コンソールから初期化したり I18n.t を実行したりする

いろいろ試すとき便利。 i18next の resStore みたいな感じ。

t = {}
I18n.backend = I18n::Backend::KeyValue.new(t)
I18n.backend.store_translations('en', {'key' => 'value'}, escape: false)
I18n.t('key') #=> "value"

参考 i18n gem advanced features - Ruby on Rails internationalization - LingoHub Blog