2014-11-14

i18n gem in pure Ruby

need en.yml & zh-hk.yml first

& just code :)

require 'i18n'

I18n.load_path = Dir['./*.yml']
I18n.available_locales = [:en , :'zh-hk']
I18n.locale = I18n.default_locale = :en

puts I18n.translate :world, :scope => 'hello'
#=> "Hello!"

puts I18n.translate :world, :scope => 'hello' , :locale => :'zh-hk'
#=> "你好!"

& you can reload it :P


I18n.reload!
puts I18n.translate :world, :scope => 'hello'
#=> "Hello!fixed"

1 則留言: