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.
charlie (Guest)
on 2006-05-08 07: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
Doug D. (Guest)
on 2006-05-08 07: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
charlie (Guest)
on 2006-05-08 09:22
Doug D. 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...
Robert W. (Guest)
on 2006-05-08 16:33
(Received via mailing list)
2006/5/8, charlie <removed_email_address@domain.invalid>:
>
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
Masao M. (Guest)
on 2006-05-08 17:22
(Received via mailing list)
Hi,

On Mon, 8 May 2006 05:27:38 +0200
charlie <removed_email_address@domain.invalid> 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.