Forum: Rails I18n Shouldn't I18n default to English?

4c1eaa228c74856babe8a895a093a500?d=identicon&s=25 Peter Alvin (remoteportal)
on 2010-02-03 12:18
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?
Adce10d7f1dbabcdab8f525a59cec32f?d=identicon&s=25 Andrés Gutiérrez (andresgutgon)
on 2010-02-03 12:25
(Received via mailing list)
I18n.t :hello_world, :default => 'Hello, world'



2010/2/3 Peter Alvin <lists@ruby-forum.com>

> 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.
402602a60e500e85f2f5dc1ff3648ecb?d=identicon&s=25 Sven Fuchs (Guest)
on 2010-02-03 12:55
(Received via mailing list)
Yup, you could use default strings.

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

http://github.com/svenfuchs/i18n/blob/master/lib/i...
Adce10d7f1dbabcdab8f525a59cec32f?d=identicon&s=25 Andrés Gutiérrez (andresgutgon)
on 2010-02-03 13:54
(Received via mailing list)
Sven, can you put an implementation example?

Example:

   1.

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

   2. Then...what?



2010/2/3 Sven Fuchs <svenfuchs@artweb-design.de>

>
>>
>> Posted via http://www.ruby-forum.com/.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "rails-i18n" group.
> To post to this group, send email to rails-i18n@googlegroups.com.
> To unsubscribe from this group, send email to
> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
> .
> 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.
5a429759e7d90e2d27d94b28e1b63cee?d=identicon&s=25 Albert Llop (mrsimo)
on 2010-02-03 14:03
(Received via mailing list)
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 Llop
Tech Department
albert@kingsofmambo.com


2010/2/3 Andrés gutiérrez <andresgutgon@gmail.com>
Adce10d7f1dbabcdab8f525a59cec32f?d=identicon&s=25 Andrés Gutiérrez (andresgutgon)
on 2010-02-03 14:10
(Received via mailing list)
Thanks Albert :)

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


2010/2/3 Albert Llop <mrsimo@gmail.com>

> 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 Groups
> "rails-i18n" group.
> To post to this group, send email to rails-i18n@googlegroups.com.
> To unsubscribe from this group, send email to
> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
> .
> 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.
402602a60e500e85f2f5dc1ff3648ecb?d=identicon&s=25 Sven Fuchs (Guest)
on 2010-02-03 14:20
(Received via mailing list)
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
http://github.com/svenfuchs/i18n/blob/master/lib/i...
Adce10d7f1dbabcdab8f525a59cec32f?d=identicon&s=25 Andrés Gutiérrez (andresgutgon)
on 2010-02-03 14:31
(Received via mailing list)
Thanks Sven. For me is clear now. I'll try it.

2010/2/3 Sven Fuchs <svenfuchs@artweb-design.de>

> 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 Groups
> "rails-i18n" group.
> To post to this group, send email to rails-i18n@googlegroups.com.
> To unsubscribe from this group, send email to
> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
> .
> 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.
Adce10d7f1dbabcdab8f525a59cec32f?d=identicon&s=25 Andrés Gutiérrez (andresgutgon)
on 2010-02-06 19:07
(Received via mailing list)
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 Fuchs <svenfuchs@artweb-design.de>

> 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 Groups
> "rails-i18n" group.
> To post to this group, send email to rails-i18n@googlegroups.com.
> To unsubscribe from this group, send email to
> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
> .
> 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.
Adce10d7f1dbabcdab8f525a59cec32f?d=identicon&s=25 Andrés Gutiérrez (andresgutgon)
on 2010-02-06 20:21
(Received via mailing list)
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
<andresgutgon@gmail.com>escribió:

>
>> This in config/enviroment.rb too?
>> http://github.com/svenfuchs/i18n/blob/master/lib/i...
>>> 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.
This topic is locked and can not be replied to.