Hi,
On Mon, 8 May 2006 08:46:05 +0200
charlie <blogyingfeng@gmail.com> wrote:
> How to set the default language in GetText?
> The default language of GetText is en,and I want to change it to another
> language,and also keep the ability to change to any other languages by
> just click the according href.
Here is a sample of application.rb:
require ''gettext/rails''
class ApplicationController < ActionController::Base
prepend_before_filter :default_locale
def default_locale
if (cookies["lang"].nil? or cookies["lang"].empty?)
GetText.locale = "zh_CN"
else
GetText.locale = cookies["lang"]
end
end
init_gettext "yourapp"
end
> Currently I use:
> class ApplicationController < ActionController::Base
> before_filter :set_charset
> def set_charset
> @headers["Content-Type"] = "text/html;
charset=utf-8"
> cookies["lang"] = ''zh_CN''
> end
> end
> But the language will not switch to my want until the next refresh.Could
> I set the default language from en to others in some way?
Because you call "set_charset" method after calling init_gettext.
BTW, you shouldn''t set Content-Type by yourself with
Ruby-GetText-Package.
It may cause other problem.
HTH,
--
.:% Masao Mutoh<mutoh@highway.ne.jp>