# Loading several locales files

**URL:** <https://www.ruby-forum.com/t/loading-several-locales-files/156311>\
**Category:** Rails I18n\
**Created:** [December 24, 2008, 10:41am UTC](https://www.ruby-forum.com/t/loading-several-locales-files/156311 "2008-12-24T10:41:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![micktaiwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@micktaiwan](https://www.ruby-forum.com/u/micktaiwan)\
**Post date:** [December 24, 2008, 10:41am UTC](https://www.ruby-forum.com/t/loading-several-locales-files/156311/1 "2008-12-24T10:41:22Z")

</div>

Hi,

If I put my 2 locales en and fr in one file (config/locales/en.yml)  
english an french locales are loaded and I can switch between the two.

But if I put the french local in a separate fr.yml file, then I get  
“translation missing: fr, email” errors.

My configuration.rb has:  
config.i18n.load\_path += Dir[File.join(RAILS\_ROOT, ‘config’, ‘locales’,  
‘\*.{rb,yml}’)]

Could someone explain this ?

Thanks for any help,  
Mickael.

---

<div class="post-metadata">

**Author:** ![micktaiwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@micktaiwan](https://www.ruby-forum.com/u/micktaiwan)\
**Post date:** [March 2, 2009, 12:14am UTC](https://www.ruby-forum.com/t/loading-several-locales-files/156311/2 "2009-03-02T00:14:20Z")

</div>

This is the solution, add this to your environment.rb.

I18n.default\_locale = ‘en’

LOCALES\_DIRECTORY = “#{RAILS\_ROOT}/config/locales”  
LOCALES\_AVAILABLE = Dir["#{LOCALES\_DIRECTORY}/\*.{rb,yml}"].collect do  
|locale\_file|  
I18n.load\_path \<\< locale\_file  
File.basename(File.basename(locale\_file, “.rb”), “.yml”)  
end.uniq.sort
