I have a gem that makes use of I18n locale dictionaries that reside in lib/locales/*.yml inside my gems folder.
When the gem is initialized I want to load these dictionaries into my rails application, but I cannot figure out how:
This is what I tried:
I18n.load_path += Dir.glob("lib/locales/*.{rb,yml}")
Unfortunately this does not work when the gem is loaded inside my Rails App. When I call I18n.t("foo")
I get "translation missing: en, foo"
.
I will probably have to provide the full path to the locales when invoking I18n.load_path, but I cannot figure out how.
Any hints?
use __FILE__
Dir.glob( File.dirname(__FILE__) + "lib/locales/*.{rb,yml}" )
For the record, if you put your locales in <GEM_ROOT>/config/locales
, they will be picked up automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With