# Shouldn't I18n default to English?

**URL:** <https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825>\
**Category:** Rails I18n\
**Created:** [February 3, 2010, 12:18pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825 "2010-02-03T12:18:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 3, 2010, 12:18pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825/1 "2010-02-03T12:18:42Z")

</div>

I’ve just started using I18n on a test application and everything is  
great except one thing:

For the fun of it I set my Firefox user agent Accept-Language to  
Italian, and my page renders this: “it, hello\_world.” Shouldn’t it say  
“hello, world” (the English phrase)?

Does I18n force you to translate every string into language in order to  
use it???

I’d much rather configure it to “use English if the desired language  
isn’t available.” How do you do that?

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 3, 2010, 12:25pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825/2 "2010-02-03T12:25:28Z")

</div>

I18n.t :hello\_world, :default =\> ‘Hello, world’

2010/2/3 Peter A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> I’d much rather configure it to "use English if the desired language  
> .  
> 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.

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 3, 2010, 12:55pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825/3 "2010-02-03T12:55:55Z")

</div>

Yup, you could use default strings.

Or - if it’s a feature that you want in your application you can use  
locale fallbacks:

> <https://github.com/ruby-i18n/i18n/blob/master/lib/i18n/backend/fallbacks.rb#L11>

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 3, 2010, 1:54pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825/4 "2010-02-03T13:54:27Z")

</div>

Sven, can you put an implementation example?

Example:

1. 

I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) This  
go in Config/enviroment?

1. Then…what?

2010/2/3 Sven F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> –  
> 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.

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 3, 2010, 2:03pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825/5 "2010-02-03T14:03:49Z")

</div>

Then you have to declare the fallbacks. For example

I18n.fallbacks[:es] = [:en, :fr, :de]  
I18n.fallbacks[:en[= [:es, :fr, :de]  
etc

## If the es translations isn’t available will pick the en one, if not the fr one ,etc

Albert L.  
Tech Department  
removed\_email\_address@domain.invalid

2010/2/3 AndrÃ©s gutiÃ©rrez [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 3, 2010, 2:10pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825/6 "2010-02-03T14:10:15Z")

</div>

Thanks Albert 🙂

This in config/enviroment.rb too?

> > I18n.fallbacks[:es] = [:en, :fr, :de]  
> > I18n.fallbacks[:en[= [:es, :fr, :de]

2010/2/3 Albert L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> Tech Department
> 
> > > Or - if it’s a feature that you want in your application you can use
> > > 
> > > > ## great except one thing:
> > > > 
> > > > [http://groups.google.com/group/rails-i18n?hl=en](http://groups.google.com/group/rails-i18n?hl=en).  
> > > > Edward V. Berard, ingeniero informÃ¡tico.
> > 
> > –  
> > –  
> > 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.

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 3, 2010, 2:31pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825/7 "2010-02-03T14:31:19Z")

</div>

Thanks Sven. For me is clear now. I’ll try it.

2010/2/3 Sven F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> config/initializers/i18n.rb) instead of environment.rb
> 
> > > > > ## great except one thing:
> > > > > 
> > > > > [http://groups.google.com/group/rails-i18n?hl=en](http://groups.google.com/group/rails-i18n?hl=en).  
> > > > > Edward V. Berard, ingeniero informÃ¡tico.
> 
> –  
> 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.

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 6, 2010, 7:07pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825/8 "2010-02-06T19:07:22Z")

</div>

Sorry but i’m tryng this but don’t work for me:  
I still have no files in English translation, so I want default for  
english  
was Spanish

#config/initializers/i18n.rb  
I18n.load\_path += Dir[File.join(RAILS\_ROOT, ‘config’, ‘locales’, ‘\*\*’,  
‘\*.{rb,yml}’)]  
I18n.default\_locale = :es  
fallbacks = I18n.fallbacks  
fallbacks.map(:en =\> :“es”)

rails 2.3.5 and ruby 1.8.7

When i run the server:  
config/initializers/i18n.rb:3: undefined method `fallbacks’ for  
I18n:Module

2010/2/3 Sven F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> config/initializers/i18n.rb) instead of environment.rb
> 
> > > > > ## great except one thing:
> > > > > 
> > > > > [http://groups.google.com/group/rails-i18n?hl=en](http://groups.google.com/group/rails-i18n?hl=en).  
> > > > > Edward V. Berard, ingeniero informÃ¡tico.
> 
> –  
> 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.

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 6, 2010, 8:21pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825/9 "2010-02-06T20:21:43Z")

</div>

I managed to fix it. I’ve seen the solution here [1]

## The code looks like this

#config/initializers/i18n.rb  
require “i18n/backend/fallbacks”  
I18n.load\_path += Dir[File.join(RAILS\_ROOT, ‘config’, ‘locales’, ‘\*\*’,  
‘\*.{rb,yml}’)]  
I18n.default\_locale = :es

## I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)

What I needed was to install the gem of sven i18n. But why?  
I think rails 2.3.5 that came with native support for internationalizing  
the  
App  
sudo gem install i18n  
Successfully installed i18n-0.3.3

[1] [http://wiki.github.com/svenfuchs/i18n/fallbacks](http://wiki.github.com/svenfuchs/i18n/fallbacks)

El 6 de febrero de 2010 19:05, AndrÃ©s gutiÃ©rrez  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)escribiÃ³:

> > This in config/enviroment.rb too?  
> > [i18n/lib/i18n/locale/fallbacks.rb at master · ruby-i18n/i18n · GitHub](http://github.com/svenfuchs/i18n/blob/master/lib/i18n/locale/fallbacks.rb)
> > 
> > > etc
> > > 
> > > > > > ## For the fun of it I set my Firefox user agent Accept-Language to
> > > > > > 
> > > > > > [http://groups.google.com/group/rails-i18n?hl=en](http://groups.google.com/group/rails-i18n?hl=en).  
> > > > > > Edward V. Berard, ingeniero informÃ¡tico.
> > 
> > –
> 
> –  
> Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
> 
> * * *
> 
> “Caminar sobre el agua y desarrollar software a partir de unas  
> especificaciones es fÃ¡cil. si ambas estÃ¡n congeladas.”  
> Edward V. Berard, ingeniero informÃ¡tico.

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

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 3, 2010, 2:20pm UTC](https://www.ruby-forum.com/t/shouldnt-i18n-default-to-english/182825/10 "2010-02-03T14:20:47Z")

</div>

On Feb 3, 2010, at 2:08 PM, AndrÃ©s gutiÃ©rrez wrote:

> This in config/enviroment.rb too?
> 
> > > I18n.fallbacks[:es] = [:en, :fr, :de]  
> > > I18n.fallbacks[:en[= [:es, :fr, :de]

That should work.

I’d recommend putting this kind of stuff into an initializer (e.g.  
config/initializers/i18n.rb) instead of environment.rb

Also, maybe you want to see

> <https://github.com/ruby-i18n/i18n/blob/master/lib/i18n/locale/fallbacks.rb>
