Sha256: 68114c6a9115b98d8f1be74b21776e60c296db2d902f4491dedda7cf6b4e5b96

Contents?: true

Size: 886 Bytes

Versions: 32

Compression:

Stored size: 886 Bytes

Contents

require 'rubygems'
require 'ramaze'

# require YAML based localization
require 'ramaze/tool/localize'

# Activate localization
# Setup localization options
class Ramaze::Tool::Localize
  Ramaze::Dispatcher::Action::FILTER << self

  trait :default_language => 'en',
        :languages => %w[ en ja cn es de it ],
        :file => lambda{|l| Ramaze::Global.root/"locale/#{l}.yaml" }
  # alternative, problematic if you want to run from another pwd.
  #     :file => "locale/%s.yaml"
end

class MainController < Ramaze::Controller
  def index
    # Enclose the strings that have to be localized with [[]]
    # This works with any templating engine.
    "<h1>[[hello world]]</h1>
     <p>[[just for fun]]</p>
     <a href='/locale/en'>[[English]]</a><br />
     <a href='/locale/de'>[[German]]</a><br />
    "
  end

  def locale(name)
    session[:LOCALE] = name
  end
end

Ramaze.start

Version data entries

32 entries across 32 versions & 5 rubygems

Version Path
Pistos-ramaze-2008.09 examples/app/localization/start.rb
Pistos-ramaze-2008.12 examples/app/localization/start.rb
Pistos-ramaze-2009.01 examples/app/localization/start.rb
Pistos-ramaze-2009.02 examples/app/localization/start.rb
Pistos-ramaze-2009.04.08 examples/app/localization/start.rb
clivecrous-ramaze-0.3.9.5 examples/localization/start.rb
manveru-ramaze-2008.07 examples/app/localization/start.rb
manveru-ramaze-2008.08 examples/app/localization/start.rb
manveru-ramaze-2008.09 examples/app/localization/start.rb
manveru-ramaze-2008.10 examples/app/localization/start.rb
manveru-ramaze-2008.12 examples/app/localization/start.rb
manveru-ramaze-2009.01 examples/app/localization/start.rb
manveru-ramaze-2009.04.01 examples/app/localization/start.rb
manveru-ramaze-2009.04.08 examples/app/localization/start.rb
manveru-ramaze-2009.04.18 examples/app/localization/start.rb
manveru-ramaze-2009.04.22 examples/app/localization/start.rb
manveru-ramaze-2009.04 examples/app/localization/start.rb
manveru-ramaze-2009.05.08 examples/app/localization/start.rb
manveru-ramaze-2009.05 examples/app/localization/start.rb
manveru-ramaze-2009.06.04 examples/app/localization/start.rb