I18n without Rails

Hi,

just having troubles to make I18n to work without Rails environment:


irb> require ‘i18n’
=> true
irb>
I18n.load_path=Dir[’/usr/lib/ruby/gems/1.9.1/gems/rails-i18n-0.6.6/rails/locale/en.yml’]
=>
["/usr/lib/ruby/gems/1.9.1/gems/rails-i18n-0.6.6/rails/locale/en.yml"]
irb>
I18n.load_path+=Dir[’/usr/lib/ruby/gems/1.9.1/gems/rails-i18n-0.6.6/rails/locale/sk.yml’]
=>
["/usr/lib/ruby/gems/1.9.1/gems/rails-i18n-0.6.6/rails/locale/en.yml",
“/usr/lib/ruby/gems/1.9.1/gems/rails-i18n-0.6.6/rails/locale/sk.yml”]
irb> I18n.locale=:sk
=> :sk
irb> I18n.default_locale=:sk
=> :sk
irb> I18n.l Time.now
I18n::MissingTranslationData: translation missing:
sk.time.formats.default
from /usr/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n.rb:289:in
handle_exception' from /usr/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n.rb:159:intranslate’
from
/usr/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/backend/base.rb:55:in
localize' from /usr/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n.rb:236:inlocalize’
from (irb):11
from /usr/bin/irb:12:in `’
irb>


What am I doing wrong ? The sk.yml DOES contain sk.time.formats.default
element !!

In addition what’s the I18n’s default load_path(s) so I won’t be
bothered to supply full paths to every translation YAML/Ruby file ?

Thanks.

http://titusd.co.uk/2010/03/04/i18n-internationalization-without-rails/

Thanks Craig, I finally made it to work. Unfortunately AFAIK there is no
default path for translation files so it has to be set manually like
does Rails framework from its root directory.

I did tried R18n library and it does work out-of-the-box. Just calling
set method and initialization is done and all translation/localisation
is working.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs