[Rg 125] patch for Content-Language based localization

Keita Yamaguchi keita.yamaguchi at gmail.com
Sun Jan 13 04:24:32 EST 2008


Hi,

This is a patch for response header "Content-Language" based localization.
Ramaze localization is session based only, but sometimes non-session
based localization is required.
For example, there is a case that locale is determined by path:

/index ... localized "index" by session based
/en/index ... localized "index" for language "en"
/ja/index ... localized "index" for language "ja"

This patch provides an easy solution like this code:

class MainController < Ramaze::Controller
  trait :lang => nil
  def index
    response["Content-Language"] = class_trait[:lang] if class_trait[:lang]
  end
end

class EnController < MainController
  map '/en'
  trait :lang => "en"
end

class JaController < MainController
  map '/en'
  trait :lang => "ja"
end

Regards,
Keita Yamaguchi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: content-language-based-localization.patch
Type: text/x-patch
Size: 2769 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/ramaze-general/attachments/20080113/76620d52/attachment.bin 


More information about the Ramaze-general mailing list