mrpete
February 3, 2010, 12:18pm
1
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?
mrpete
February 3, 2010, 12:25pm
2
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.
mrpete
February 3, 2010, 12:55pm
3
Yup, you could use default strings.
Or - if it’s a feature that you want in your application you can use
locale fallbacks:
mrpete
February 3, 2010, 1:54pm
4
Sven, can you put an implementation example?
Example:
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) This
go in Config/enviroment?
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.
mrpete
February 3, 2010, 2:03pm
5
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]
mrpete
February 3, 2010, 2:10pm
6
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. [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.
mrpete
February 3, 2010, 2:31pm
7
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.
mrpete
February 6, 2010, 7:07pm
8
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.
mrpete
February 6, 2010, 8:21pm
9
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.
mrpete
February 3, 2010, 2:20pm
10
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
# Locale Fallbacks
#
# Extends the I18n module to hold a fallbacks instance which is set to an
# instance of I18n::Locale::Fallbacks by default but can be swapped with a
# different implementation.
#
# Locale fallbacks will compute a number of fallback locales for a given locale.
# For example:
#
# <pre><code>
# I18n.fallbacks[:"es-MX"] # => [:"es-MX", :es, :en] </code></pre>
#
# Locale fallbacks always fall back to
#
# * all parent locales of a given locale (e.g. :es for :"es-MX") first,
# * the current default locales and all of their parents second
#
# The default locales are set to [] by default but can be set to something else.
#
# One can additionally add any number of additional fallback locales manually.
This file has been truncated. show original