Forum: Ruby on Rails Gettext not worked in firefox,but done well under IE

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2e5a77bf26f7cab677f33537c8495fbf?d=identicon&s=25 charlie (Guest)
on 2006-05-08 05:27
Anyone who has met such a kind of problem? I am adding i18n
characteristics to my webapp using gettext,it works under IE,while not
under firefox.
here is my codes:
po:
po\zh_CN\myapp.po

after rake makemo, i have got:
locale\zh_CN\LC_MESSAGES\myapp.mo

require 'gettext/rails'
class ApplicationController < ActionController::Base
	init_gettext "myapp"
end

Then I use the following to have a test in the application.rhtml
<%= local %>
<% local=("zh_CN") %>
<%= local %>
<%= _("Login") %>
in IE,it can display as follows:
en
zh_CN
ç?»é??

but in firefox,it can not work:
en
zh_CN
Login

Am i wrong or ignore some procedures?

Thanks
Charlie
F641ba2e0fc906fb77d74b52cf59d187?d=identicon&s=25 Doug Dupory (doug)
on 2006-05-08 05:50
I've gotten GetText 1.4 and Firefox 1.5.0.3 to work. Not sure how you
set the lang (locale). I have mine be the first of
request.env['HTTP_ACCEPT_LANGUAGE'].

DD
2e5a77bf26f7cab677f33537c8495fbf?d=identicon&s=25 charlie (Guest)
on 2006-05-08 07:22
Doug Dupory wrote:
> I've gotten GetText 1.4 and Firefox 1.5.0.3 to work. Not sure how you
> set the lang (locale). I have mine be the first of
> request.env['HTTP_ACCEPT_LANGUAGE'].
>
> DD

It seems that I can not use GetText.local= to set lang value,although I
have found it in the API of GetText :
http://www.yotabanana.com/hiki/ruby-gettext-api.ht...
61b533b3b2330585c25c761ce28d45ec?d=identicon&s=25 Robert Wagner (Guest)
on 2006-05-08 14:33
(Received via mailing list)
2006/5/8, charlie <blogyingfeng@gmail.com>:
>
maybe this helps:
http://manuals.rubyonrails.com/read/book/16

it says:

Ruby-GetText chooses the current language by following these rules in
the given order:

   1. the first value passed the 'locale' parameter of
GetText.bindtextdomain method call
   2. 'lang' value of QUERY_STRING
   3. 'lang' value of the Cookie
   4. the value of HTTP_ACCEPT_LANGUAGE
   5. or default 'en' (English).

ciao,
  robert
9fe908f5593444a40be14a424c372e58?d=identicon&s=25 Masao Mutoh (Guest)
on 2006-05-08 15:22
(Received via mailing list)
Hi,

On Mon, 8 May 2006 05:27:38 +0200
charlie <blogyingfeng@gmail.com> wrote:

> require 'gettext/rails'
> en
> zh_CN
> ç?»é??
>
> but in firefox,it can not work:
> en
> zh_CN
> Login
>
> Am i wrong or ignore some procedures?

Did your code work?

I think you need to use locale not local.
and also local=("zh_CN") set "zh_CN" to "local" variable.

If you really want to work this sample, then

> require 'gettext/rails'
> class ApplicationController < ActionController::Base
GetText.locale = "zh_CN"
> 	init_gettext "myapp"
> end


BTW,
Try "zh" locale instead of "zh_CN".

locale\zh_CN\LC_MESSAGES\myapp.mo
  -> locale\zh\LC_MESSAGES\myapp.mo

I suspect your locale of FireFox is "zh" not "zh_CN".
(Check Edit -> Preferences -> Advanced -> Edit Languages)
This topic is locked and can not be replied to.