Shouldn't I18n default to English?

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?

I18n.t :hello_world, :default => ‘Hello, world’

2010/2/3 Peter A. [email protected]

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.


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

Yup, you could use default strings.

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

Sven, can you put an implementation example?

Example:

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

  1. Then…what?

2010/2/3 Sven F. [email protected]

Posted via 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 [email protected].
To unsubscribe from this group, send email to
[email protected][email protected]
.
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en.


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

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
[email protected]

2010/2/3 Andrés gutiérrez [email protected]

Thanks Albert :slight_smile:

This in config/enviroment.rb too?

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

2010/2/3 Albert L. [email protected]

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.
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 [email protected].
To unsubscribe from this group, send email to
[email protected][email protected]
.
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en.


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

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

2010/2/3 Sven F. [email protected]

config/initializers/i18n.rb) instead of environment.rb

great except one thing:

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 [email protected].
To unsubscribe from this group, send email to
[email protected][email protected]
.
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en.


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

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. [email protected]

config/initializers/i18n.rb) instead of environment.rb

great except one thing:

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 [email protected].
To unsubscribe from this group, send email to
[email protected][email protected]
.
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en.


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

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

El 6 de febrero de 2010 19:05, Andrés gutiérrez
[email protected]escribió:

This in config/enviroment.rb too?
i18n/lib/i18n/locale/fallbacks.rb at master · ruby-i18n/i18n · GitHub

etc

For the fun of it I set my Firefox user agent Accept-Language to

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.

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