So that's the problem. In my application globalize2 returns a NIL string if there's no translation on some record, instead of falling back to default_locale. I wonder how to enable thin functionality? Does anyone figured that out?
Asked
Active
Viewed 1,675 times
3 Answers
10
Install sven fuchs's i18n library from http://github.com/svenfuchs/i18n
Then, in your environment.rb :
require "i18n/backend/fallbacks"
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
using :"en-US" as a default locale:
I18n.default_locale = :"en-US"
I18n.fallbacks[:ca] # => [:ca, :"en-US", :en]
I18n.fallbacks :dk => [:"se-FI", :"fi-FI"] # => [:dk, :"se-FI", :se, :"fi-FI", :fi, :"en-US", :en]

Joris
- 617
- 6
- 10
-
Thanks man, but I ran into some problems using thin plugin I18n. But your answer is correct. – Filip Jan 29 '10 at 11:49
1
In latest i18n gem (0.7.0) I have found it necessary to define fallback locales like this (in config/application.rb
):
# Custom I18n fallbacks
config.after_initialize do
I18n.fallbacks = I18n::Locale::Fallbacks.new(at: :"de-DE", ch: :"de-DE", gb: :"en-US")
end
You also need to set config.i18n.fallbacks = true
in all config/environments/*.rb
files.

Paweł Gościcki
- 9,066
- 5
- 70
- 81
0
This worked for me (i18n gem version 0.4x didn't work).
# config/environment.rb
config.gem 'i18n', :version => '0.3.7'
# config/initializers/i18n.rb
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)

Zubin
- 9,422
- 7
- 48
- 52