# I can't make i18n work on rails

**URL:** <https://www.ruby-forum.com/t/i-cant-make-i18n-work-on-rails/182065>\
**Category:** Rails I18n\
**Created:** [January 22, 2010, 7:28am UTC](https://www.ruby-forum.com/t/i-cant-make-i18n-work-on-rails/182065 "2010-01-22T07:28:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wisemaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@wisemaster](https://www.ruby-forum.com/u/wisemaster)\
**Post date:** [January 22, 2010, 7:28am UTC](https://www.ruby-forum.com/t/i-cant-make-i18n-work-on-rails/182065/1 "2010-01-22T07:28:37Z")

</div>

Hi,

I’m following this guide [Rails Internationalization (I18n) API — Ruby on Rails Guides](http://guides.rubyonrails.org/i18n.html)

but I can’t make it works.

it says: “Rails adds all .rb and .yml files from the config/locales  
directory to your translations load path, automatically. The default  
en.yml locale in this directory contains a sample pair of translation  
strings”

firstly when I create a rails app using the rails command it doesn’t  
not create nether a config/locales directory nor en.yml file.

secondly I want to change default language, I added this line to  
enviroment.rb as the guide says

config.i18n.default\_locale = :en

but it gives me an error: undefined method `i18n’ for  
#Rails::Configuration:0xb78ac64c

Please I need a hand with this.

---

<div class="post-metadata">

**Author:** ![wisemaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@wisemaster](https://www.ruby-forum.com/u/wisemaster)\
**Post date:** [January 22, 2010, 7:40am UTC](https://www.ruby-forum.com/t/i-cant-make-i18n-work-on-rails/182065/2 "2010-01-22T07:40:20Z")

</div>

On Fri, Jan 22, 2010 at 01:19, Omar R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> firstly when I create a rails app using the rails command it doesn’t  
> not create nether a config/locales directory nor en.yml file.

I just tried generating a new Rails app with Rails 2.3.5. I got a  
config/locales/en.yml file.

> secondly I want to change default language, I added this line to  
> enviroment.rb as the guide says
> 
> config.i18n.default\_locale = :en
> 
> but it gives me an error: undefined method `i18n’ for  
> #Rails::Configuration:0xb78ac64c

Works fine for me. What Rails version are you using? Does the top if  
yopur environment.rb file say

# Specifies gem version of Rails to use when vendor/rails is not present

RAILS\_GEM\_VERSION = ‘2.3.5’ unless defined? RAILS\_GEM\_VERSION

?

---

<div class="post-metadata">

**Author:** ![wisemaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@wisemaster](https://www.ruby-forum.com/u/wisemaster)\
**Post date:** [January 30, 2010, 11:01pm UTC](https://www.ruby-forum.com/t/i-cant-make-i18n-work-on-rails/182065/3 "2010-01-30T23:01:42Z")

</div>

mine says:

RAILS\_GEM\_VERSION = ‘2.1.0’ unless defined? RAILS\_GEM\_VERSION

this should be the problem, aparrently rails command used without  
version argument uses 2.1.0 as default.

Thanks a lot Henrik!

---

<div class="post-metadata">

**Author:** ![wisemaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@wisemaster](https://www.ruby-forum.com/u/wisemaster)\
**Post date:** [February 1, 2010, 4:09am UTC](https://www.ruby-forum.com/t/i-cant-make-i18n-work-on-rails/182065/4 "2010-02-01T04:09:07Z")

</div>

You need to run gem update to get a later version of rails

Justin

---

<div class="post-metadata">

**Author:** ![wisemaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@wisemaster](https://www.ruby-forum.com/u/wisemaster)\
**Post date:** [February 1, 2010, 4:32pm UTC](https://www.ruby-forum.com/t/i-cant-make-i18n-work-on-rails/182065/5 "2010-02-01T16:32:31Z")

</div>

I still have problems,

I did gem update, then gem list looks like this:

$ gem list

\*\*\* LOCAL GEMS \*\*\*

…  
rails (2.3.5, 2.3.4)  
…

Despite it, when a do rails project-name, the config/enviroment.rb has  
RAILS\_GEM\_VERSION = ‘2.1.0’ unless defined? RAILS\_GEM\_VERSION.

I have netbeans6.8 installed, I don’t know if it has its own version  
of rails and in somehow is replacing 2.3.5 …

Thanks

---

<div class="post-metadata">

**Author:** ![wisemaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@wisemaster](https://www.ruby-forum.com/u/wisemaster)\
**Post date:** [February 1, 2010, 4:38pm UTC](https://www.ruby-forum.com/t/i-cant-make-i18n-work-on-rails/182065/6 "2010-02-01T16:38:58Z")

</div>

Your top enviroment.rb says this:  
RAILS\_GEM\_VERSION = ‘2.1.0’ unless defined? RAILS\_GEM\_VERSION.

Should say this:  
RAILS\_GEM\_VERSION = ‘2.3.5’ unless defined? RAILS\_GEM\_VERSION.

Change it.

2010/2/1 Omar R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> …  
> On Jan 31, 11:08 pm, Justin MacCarthy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > > this should be the problem, aparrently rails command used without
> > > 
> > > > I just tried generating a new Rails app with Rails 2.3.5. I got a  
> > > > Works fine for me. What Rails version are you using? Does the top if  
> > > > Groups “rails-i18n” group.  
> > > > You received this message because you are subscribed to the Google G.  
> > > > “rails-i18n” group.  
> > > > To post to this group, send email to removed\_email\_address@domain.invalid.  
> > > > To unsubscribe from this group, send email to  
> > > > removed\_email\_address@domain.invalid[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > > > .  
> > > > For more options, visit this group at  
> > > > [http://groups.google.com/group/rails-i18n?hl=en](http://groups.google.com/group/rails-i18n?hl=en).

–  
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
