/usr/share/doc/ruby-ramaze/examples/app/localization/start.rb is in ruby-ramaze 2012.12.08-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # -*- coding: utf-8 -*-
require 'rubygems'
require 'ramaze'
# require YAML based localization
require 'ramaze/helper/localize'
#
# Old Dispatcher::Action::FILTER style localization.
#
class MainController < Ramaze::Controller
helper :localize
def index
# Enclose the strings that have to be localized with {}
"<h1>{hello world}</h1>
<p>{just for fun}</p>
<a href='/locale/en'>{english}</a><br />
<a href='/locale/ja'>{japanese}</a><br />
<a href='/locale/de'>{german}</a><br />
"
end
def locale(name)
session[:lang] = name
redirect r(:/)
end
# for Localization
alias :raw_wrap_action_call :wrap_action_call
def wrap_action_call(action, &block)
localize(raw_wrap_action_call(action, &block))
end
private
Dictionary = Ramaze::Helper::Localize::Dictionary.new
Dir.glob('./locale/*.yaml').each do |path|
Dictionary.load(File.basename(path, '.yaml').intern, :yaml => path)
end
def localize_dictionary
Dictionary
end
end
Ramaze.start
|